コード例 #1
0
        public static BasicArraysObject Create()
        {
            var obj = new BasicArraysObject()
            {
                BoolNullArray       = null,
                BoolZeroLengthArray = new bool[0],
                ByteArray           = new byte[1024],
                UIntArray           = new uint[1024],
                IntArray            = new int[1024],
                DoubleArray         = new double[1024],
                ShortArray          = new short[1024],
                UShortArray         = new ushort[1024],
                FloatArray          = new float[1024],
                StringArray         = new[] { string.Empty, null, "Test1", "Test 2 Test", string.Empty, "Test 3 Test", null },
            };

            var random = new Random();

            random.NextBytes(obj.ByteArray);

            for (var i = 0; i < obj.UIntArray.Length; i++)
            {
                obj.UIntArray[i]   = (uint)random.Next(0, int.MaxValue);
                obj.IntArray[i]    = random.Next();
                obj.DoubleArray[i] = random.NextDouble();
                obj.UShortArray[i] = (ushort)random.Next(ushort.MinValue, ushort.MaxValue);
                obj.ShortArray[i]  = (short)random.Next(short.MinValue, short.MaxValue);
                obj.FloatArray[i]  = (float)random.NextDouble();
            }

            return(obj);
        }
コード例 #2
0
 public static void Comparer(BasicArraysObject expected, BasicArraysObject actual)
 {
     Assert.Equal(expected.BoolNullArray, actual.BoolNullArray);
     Assert.Empty(actual.BoolZeroLengthArray);
     Assert.Equal(expected.ByteArray, actual.ByteArray);
     Assert.Equal(expected.DoubleArray, actual.DoubleArray);
     Assert.Equal(expected.UIntArray, actual.UIntArray);
     Assert.Equal(expected.IntArray, actual.IntArray);
     Assert.Equal(expected.ShortArray, actual.ShortArray);
     Assert.Equal(expected.UShortArray, actual.UShortArray);
     Assert.Equal(expected.FloatArray, actual.FloatArray);
     Assert.Equal(expected.StringArray, actual.StringArray);
 }