public void JsonArrayCopytoFunctionalTest()
        {
            int seed = 1;

            for (int i = 0; i < iterationCount / 10; i++)
            {
                seed++;
                Log.Info("Seed: {0}", seed);
                Random rndGen = new Random(seed);

                bool retValue = true;

                JsonArray   sourceJson = SpecialJsonValueHelper.CreatePrePopulatedJsonArray(seed, arrayLength);
                JsonValue[] destJson   = new JsonValue[arrayLength];
                sourceJson.CopyTo(destJson, 0);

                for (int k = 0; k < destJson.Length; k++)
                {
                    if (destJson[k] != sourceJson[k])
                    {
                        retValue = false;
                    }
                }

                Assert.True(retValue, "[JsonArrayCopytoFunctionalTest] JsonArray.CopyTo() failed to function properly. destJson.GetLength(0) = " + destJson.GetLength(0));
            }
        }
Beispiel #2
0
        public void CopyToTest()
        {
            JsonValue item1  = AnyInstance.AnyJsonValue1;
            JsonValue item2  = AnyInstance.AnyJsonValue2;
            JsonArray target = new JsonArray(item1, item2);

            JsonValue[] array = new JsonValue[target.Count + 1];

            target.CopyTo(array, 0);
            Assert.Equal(item1, array[0]);
            Assert.Equal(item2, array[1]);

            target.CopyTo(array, 1);
            Assert.Equal(item1, array[1]);
            Assert.Equal(item2, array[2]);

            ExceptionHelper.Throws <ArgumentNullException>(() => target.CopyTo(null, 0));
            ExceptionHelper.Throws <ArgumentOutOfRangeException>(() => target.CopyTo(array, -1));
            ExceptionHelper.Throws <ArgumentException>(() => target.CopyTo(array, array.Length - target.Count + 1));
        }