Esempio n. 1
0
        public void ReadBoolean3DArrayTest()
        {
            List <List <List <bool> > > values = new List <List <List <bool> > >()
            {
                new List <List <bool> >()
                {
                    new List <bool>()
                    {
                        false, true
                    },
                    new List <bool>()
                    {
                        true
                    },
                },
                new List <List <bool> >()
                {
                    new List <bool>()
                    {
                        false
                    },
                },
            };

            DeserializationHelper.Array3DHelper <bool>(values);
        }
Esempio n. 2
0
        public void ReadInt163DArrayTest()
        {
            List <List <List <short> > > values = new List <List <List <short> > >()
            {
                new List <List <short> >()
                {
                    new List <short>()
                    {
                        -1, 0, short.MinValue, 1000, short.MaxValue
                    },
                    new List <short>()
                    {
                        -1, short.MaxValue, 10
                    },
                },
                new List <List <short> >()
                {
                    new List <short>()
                    {
                        0x02, 0x13, 0x29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <short>(values);
        }
Esempio n. 3
0
        public void ReadInt323DArrayTest()
        {
            List <List <List <int> > > values = new List <List <List <int> > >()
            {
                new List <List <int> >()
                {
                    new List <int>()
                    {
                        int.MaxValue, 10000, 0, -1000, 100, int.MinValue
                    },
                    new List <int>()
                    {
                        0x00, 0xFD, -12
                    },
                },
                new List <List <int> >()
                {
                    new List <int>()
                    {
                        0x02, 0x13, -29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <int>(values);
        }
Esempio n. 4
0
        /// <summary>
        /// Helps test 1D arrays.
        /// </summary>
        /// <typeparam name="T">Type of the underlying value stored in the array.</typeparam>
        /// <param name="values">The values.</param>
        /// <param name="nullable">If set to <c>true</c> [nullable].</param>
        public static void Array1DHelper <T>(List <T> values, bool nullable)
        {
            System.IO.Stream stream = new SerializedStreamBuilder()
                                      .Array <T>(values, nullable)
                                      .ToStream();

            BinaryReader reader = new BinaryReader(stream, DeserializationHelper.CannedVersion);

            string methodName = DeserializationHelper.GetReaderMethodName(typeof(T));

            MethodInfo methodInfo = GetReaderMethodInfoFromName <T>(methodName, reader);

            List <T> actual = (List <T>)methodInfo.Invoke(reader, new object[] { string.Empty, nullable, 1U });

            if (values != null)
            {
                Assert.IsNotNull(actual);
            }
            else
            {
                Assert.IsNull(actual);
            }

            TestHelper.AssertCollectionEquals <T>(values, actual);
        }
Esempio n. 5
0
        /// <summary>
        /// Helps test empty arrays.
        /// </summary>
        /// <typeparam name="T">Type of the underlying value stored in the array.</typeparam>
        /// <param name="nullable">If set to <c>true</c> [nullable].</param>
        public static void EmptyArrayHelper <T>(bool nullable)
        {
            SerializedStreamBuilder builder = new SerializedStreamBuilder();

            if (nullable)
            {
                builder.NullableFlag(false);
            }

            System.IO.Stream stream = builder
                                      .Size(0)
                                      .ToStream();

            BinaryReader reader = new BinaryReader(stream, DeserializationHelper.CannedVersion);

            for (uint rank = 1; rank <= 4; rank++)
            {
                string methodName = DeserializationHelper.GetReaderMethodName(typeof(T));

                MethodInfo methodInfo = GetReaderMethodInfoFromName <T>(methodName, reader);

                ICollection obj = (ICollection)methodInfo.Invoke(reader, new object[] { string.Empty, nullable, rank });
                Assert.AreEqual <int>(obj.Count, 0);

                stream.Seek(0L, System.IO.SeekOrigin.Begin);
            }
        }
Esempio n. 6
0
        public void ReadByte3DArrayTest()
        {
            List <List <List <byte> > > values = new List <List <List <byte> > >()
            {
                new List <List <byte> >()
                {
                    new List <byte>()
                    {
                        0x01, 0x02
                    },
                    new List <byte>()
                    {
                        0x00, 0xFD, 0x98
                    },
                },
                new List <List <byte> >()
                {
                    new List <byte>()
                    {
                        0x02, 0x13, 0x29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <byte>(values);
        }
        public void ReadString3DArrayTest()
        {
            List <List <List <string> > > values = new List <List <List <string> > >()
            {
                new List <List <string> >()
                {
                    new List <string>()
                    {
                        "foo", "bar"
                    },
                    new List <string>()
                    {
                        "no", "no", "and no"
                    },
                },
                new List <List <string> >()
                {
                    new List <string>()
                    {
                        "what?", "where?", "who?"
                    },
                },
            };

            DeserializationHelper.Array3DHelper <string>(values);
        }
Esempio n. 8
0
        public void ReadInt643DArrayTest()
        {
            List <List <List <long> > > values = new List <List <List <long> > >()
            {
                new List <List <long> >()
                {
                    new List <long>()
                    {
                        0, 50, -100, long.MinValue, -10000, long.MaxValue
                    },
                    new List <long>()
                    {
                        0x10, long.MinValue, 0x98
                    },
                },
                new List <List <long> >()
                {
                    new List <long>()
                    {
                        long.MinValue, 0x13, 0x29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <long>(values);
        }
Esempio n. 9
0
        public void ReadFloat3DArrayTest()
        {
            List <List <List <float> > > values = new List <List <List <float> > >()
            {
                new List <List <float> >()
                {
                    new List <float>()
                    {
                        0x01, 1.1F, 2.2F, 3.3F
                    },
                    new List <float>()
                    {
                        -2.5F, 0xFD, 3000
                    },
                },
                new List <List <float> >()
                {
                    new List <float>()
                    {
                        1.5F, 2.2F, -1e10F
                    },
                },
            };

            DeserializationHelper.Array3DHelper <float>(values);
        }
Esempio n. 10
0
        public void ReadEnum3DArrayTest()
        {
            List <List <List <TestStatus> > > values = new List <List <List <TestStatus> > >()
            {
                new List <List <TestStatus> >()
                {
                    new List <TestStatus>()
                    {
                        TestStatus.Late, TestStatus.Late, TestStatus.Early, TestStatus.OnTime, TestStatus.Early
                    },
                    new List <TestStatus>()
                    {
                        TestStatus.Early, TestStatus.Late, TestStatus.Late, TestStatus.OnTime
                    },
                },
                new List <List <TestStatus> >()
                {
                    new List <TestStatus>()
                    {
                        TestStatus.OnTime, TestStatus.Early, TestStatus.Late
                    },
                },
            };

            DeserializationHelper.Array3DHelper <TestStatus>(values);
        }
Esempio n. 11
0
        public void ReadUInt643DArrayTest()
        {
            List <List <List <ulong> > > values = new List <List <List <ulong> > >()
            {
                new List <List <ulong> >()
                {
                    new List <ulong>()
                    {
                        1000, 100, 0, ulong.MinValue, 666, ulong.MaxValue
                    },
                    new List <ulong>()
                    {
                        0x00, ulong.MaxValue, 0x98
                    },
                },
                new List <List <ulong> >()
                {
                    new List <ulong>()
                    {
                        0x02, 0x13, ulong.MaxValue
                    },
                },
            };

            DeserializationHelper.Array3DHelper <ulong>(values);
        }
Esempio n. 12
0
        /// <summary>
        /// Helps test 2D arrays.
        /// </summary>
        /// <typeparam name="T">Type of the underlying value stored in the array.</typeparam>
        /// <param name="values">The values.</param>
        /// <param name="nullable">If set to <c>true</c> [nullable].</param>
        public static void Array2DHelper <T>(List <List <T> > values, bool nullable)
        {
            System.IO.Stream stream = new SerializedStreamBuilder()
                                      .Array <T>(values, nullable)
                                      .ToStream();

            BinaryReader reader = new BinaryReader(stream, DeserializationHelper.CannedVersion);

            string methodName = DeserializationHelper.GetReaderMethodName(typeof(T));

            MethodInfo methodInfo = GetReaderMethodInfoFromName <T>(methodName, reader);

            List <List <T> > actual = (List <List <T> >)methodInfo.Invoke(reader, new object[] { string.Empty, nullable, 2U });

            Assert.IsNotNull(actual);

            using (IEnumerator <List <T> > valuesEnumerator = values.GetEnumerator())
            {
                using (IEnumerator <List <T> > actualEnumerator = actual.GetEnumerator())
                {
                    Assert.AreEqual <int>(values.Count, actual.Count);

                    while (valuesEnumerator.MoveNext() && actualEnumerator.MoveNext())
                    {
                        TestHelper.AssertCollectionEquals <T>(valuesEnumerator.Current, actualEnumerator.Current);
                    }
                }
            }
        }
Esempio n. 13
0
        public void ReadUInt163DArrayTest()
        {
            List <List <List <ushort> > > values = new List <List <List <ushort> > >()
            {
                new List <List <ushort> >()
                {
                    new List <ushort>()
                    {
                        1, 0, ushort.MinValue, 1000, ushort.MaxValue
                    },
                    new List <ushort>()
                    {
                        ushort.MinValue, 2
                    },
                },
                new List <List <ushort> >()
                {
                    new List <ushort>()
                    {
                        0x02, ushort.MinValue, 0x29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <ushort>(values);
        }
Esempio n. 14
0
        public void ReadUInt323DArrayTest()
        {
            List <List <List <uint> > > values = new List <List <List <uint> > >()
            {
                new List <List <uint> >()
                {
                    new List <uint>()
                    {
                        55, 123, 0, uint.MinValue, 5, uint.MaxValue
                    },
                    new List <uint>()
                    {
                        0x00, uint.MinValue, 0x98
                    },
                },
                new List <List <uint> >()
                {
                    new List <uint>()
                    {
                        0x02, uint.MinValue, 0x29
                    },
                },
            };

            DeserializationHelper.Array3DHelper <uint>(values);
        }
Esempio n. 15
0
        public void ReadUInt321DArrayTest()
        {
            List <uint> values = new List <uint>()
            {
                55, 123, 0, uint.MinValue, 5, uint.MaxValue
            };

            DeserializationHelper.Array1DHelper <uint>(values);
        }
Esempio n. 16
0
        public void ReadFloat1DArrayTest()
        {
            List <float> values = new List <float>()
            {
                0x01, 1.1F, 2.2F, 3.3F
            };

            DeserializationHelper.Array1DHelper <float>(values);
        }
Esempio n. 17
0
        public void ReadUInt641DArrayTest()
        {
            List <ulong> values = new List <ulong>()
            {
                1000, 100, 0, ulong.MinValue, 666, ulong.MaxValue
            };

            DeserializationHelper.Array1DHelper <ulong>(values);
        }
Esempio n. 18
0
        public void ReadDouble1DArrayTest()
        {
            List <double> values = new List <double>()
            {
                0x01, 1.1F, 2.2F, 3.3e300
            };

            DeserializationHelper.Array1DHelper <double>(values);
        }
Esempio n. 19
0
        public void ReadByte1DArrayTest()
        {
            List <byte> values = new List <byte>()
            {
                0x01, 0x02, 0x32, 0x00, 0x23, 0x90, 0xFE, 0xFF, 0xA3, 0xB8, 0x99
            };

            DeserializationHelper.Array1DHelper <byte>(values);
        }
Esempio n. 20
0
        public void ReadString1DArrayTest()
        {
            List <string> values = new List <string>()
            {
                "foo", "bar"
            };

            DeserializationHelper.Array1DHelper <string>(values);
        }
Esempio n. 21
0
        public void ReadBoolean1DArrayTest()
        {
            List <bool> values = new List <bool>()
            {
                false, true
            };

            DeserializationHelper.Array1DHelper <bool>(values);
        }
Esempio n. 22
0
        public void ReadInt641DArrayTest()
        {
            List <long> values = new List <long>()
            {
                0, 50, -100, long.MinValue, -10000, long.MaxValue
            };

            DeserializationHelper.Array1DHelper <long>(values);
        }
Esempio n. 23
0
        public void ReadEnum1DArrayTest()
        {
            List <TestStatus> values = new List <TestStatus>()
            {
                TestStatus.Late, TestStatus.OnTime, TestStatus.Early, TestStatus.OnTime, TestStatus.Late
            };

            DeserializationHelper.Array1DHelper <TestStatus>(values);
        }
Esempio n. 24
0
        public void ReadUInt161DArrayTest()
        {
            List <ushort> values = new List <ushort>()
            {
                1, 0, ushort.MinValue, 1000, ushort.MaxValue
            };

            DeserializationHelper.Array1DHelper <ushort>(values);
        }
Esempio n. 25
0
        public void ReadInt321DArrayTest()
        {
            List <int> values = new List <int>()
            {
                int.MaxValue, 10000, 0, -1000, 100, int.MinValue
            };

            DeserializationHelper.Array1DHelper <int>(values);
        }
Esempio n. 26
0
        public void ReadBinary1DArrayTest()
        {
            List <byte[]> values = new List <byte[]>()
            {
                new byte[] { 0x01, 0x02, 0x32 },
                new byte[] { 0x01, 0x02 },
            };

            DeserializationHelper.BinaryArrayHelper(values);
        }
Esempio n. 27
0
        public void ReadDouble2DArrayTest()
        {
            List <List <double> > values = new List <List <double> >()
            {
                new List <double>()
                {
                    0x01, 1.1F, 2.2F, 3.3e300
                },
                new List <double>()
                {
                    -2.5F, 0xFD, 3000
                },
            };

            DeserializationHelper.Array2DHelper <double>(values);
        }
Esempio n. 28
0
        public void ReadString2DArrayTest()
        {
            List <List <string> > values = new List <List <string> >()
            {
                new List <string>()
                {
                    "foo", "bar"
                },
                new List <string>()
                {
                    "no", "no", "and no"
                },
            };

            DeserializationHelper.Array2DHelper <string>(values);
        }
Esempio n. 29
0
        public void ReadDouble4DArrayTest()
        {
            List <List <List <List <double> > > > values = new List <List <List <List <double> > > >()
            {
                new List <List <List <double> > >()
                {
                    new List <List <double> >()
                    {
                        new List <double>()
                        {
                            0x01, 1.1F, 2.2F, 3.3e300
                        },
                        new List <double>()
                        {
                            -2.5F, 0xFD, 3000
                        },
                    },
                    new List <List <double> >()
                    {
                        new List <double>()
                        {
                            1.5F, 2.2F, -1e10F
                        },
                    },
                },
                new List <List <List <double> > >()
                {
                    new List <List <double> >()
                    {
                        new List <double>()
                        {
                            0x12, 0x23
                        },
                    },
                },
            };

            DeserializationHelper.Array4DHelper <double>(values);
        }
Esempio n. 30
0
 public void ReadEmptyEnumArray()
 {
     DeserializationHelper.EmptyArrayHelper <TestStatus>();
 }