Ejemplo n.º 1
0
        private static PrimitiveCollection GetPrimitiveCollection(IRandomNumberGenerator random)
        {
            TestValues.CreatePrimitiveValuesWithMetadata(true);
            PrimitiveValue val      = random.ChooseFrom(TestValues.CreatePrimitiveValuesWithMetadata(true));
            int            numItems = random.NextFromRange(1, 3);
            var            newItems = Enumerable.Range(0, numItems).Select(x => TestValues.GetDifferentPrimitiveValue(val));
            var            payload  = new PrimitiveCollection(newItems.ToArray());

            return(payload);
        }
Ejemplo n.º 2
0
        private static PrimitiveMultiValue GenerateSimilarPrimitiveMultiValue(IRandomNumberGenerator random, PrimitiveMultiValue currentInstance)
        {
            PrimitiveMultiValue instance = ((PrimitiveMultiValue)currentInstance.DeepCopy());

            if (instance.Count != 0)
            {
                PrimitiveValue val      = instance.First();
                int            numItems = random.NextFromRange(1, 3);
                var            newItems = Enumerable.Range(0, numItems).Select(x => TestValues.GetDifferentPrimitiveValue(val));
                instance = new PrimitiveMultiValue(val.FullTypeName, false, newItems.ToArray());
            }

            return(instance);
        }
Ejemplo n.º 3
0
        private static ComplexInstance GenerateSimilarComplexInstance(IRandomNumberGenerator random, ComplexInstance currentInstance, bool randomizePropertyValues = false)
        {
            ComplexInstance instance = ((ComplexInstance)currentInstance.DeepCopy());

            if (!randomizePropertyValues)
            {
                return(instance);
            }

            foreach (var property in instance.Properties)
            {
                PrimitiveProperty primitive = property as PrimitiveProperty;
                if (primitive != null)
                {
                    primitive.Value = TestValues.GetDifferentPrimitiveValue(primitive.Value);
                }

                ComplexProperty complex = property as ComplexProperty;
                if (complex != null)
                {
                    complex.Value = GenerateSimilarComplexInstance(random, complex.Value);
                }

                PrimitiveMultiValueProperty pmultival = property as PrimitiveMultiValueProperty;
                if (pmultival != null)
                {
                    pmultival.Value = GenerateSimilarPrimitiveMultiValue(random, pmultival.Value);
                }

                ComplexMultiValueProperty cmultival = property as ComplexMultiValueProperty;
                if (cmultival != null)
                {
                    cmultival.Value = GenerateSimilarComplexMultiValue(random, cmultival.Value);
                }
            }

            return(instance);
        }