Esempio n. 1
0
        public Property Constructor_CreateAValidDictionary()
        {
            var threshold = 10;

            return(Prop.ForAll <Tuple <int, string>[]>((keyValues) => {
                var model = new Dictionary <int, string>();
                keyValues.ForEach(kv => model[kv.Item1] = kv.Item2);

                var hybrid = new HybridDictionary <int, string>(threshold);
                keyValues.ForEach(kv => hybrid[kv.Item1] = kv.Item2);

                return model.OrderBy(kvp => kvp.Key).SequenceEqual(hybrid.OrderBy(kvp => kvp.Key))
                .Classify(hybrid.Count <= 1, "Single")
                .Classify(hybrid.Count > 1 && hybrid.Count <= threshold, "List")
                .Classify(hybrid.Count > threshold, "Dictionary")
                .Classify(model.Count != keyValues.Length, "None trivial")
                .Classify(model.Count == keyValues.Length, "trivial");
            }));
        }
Esempio n. 2
0
        protected override void ComputeString(DescriptionBuilder context)
        {
            context.Append("{");
            var first = true;

            foreach (var it in _Attributes.OrderBy(kvp => kvp.Key))
            {
                if (!first)
                {
                    context.Append(",");
                }

                context.Append($@"""{it.Key}"":");

                using (context.PushContext(it.Key))
                {
                    it.Value.BuilString(context);
                }

                first = false;
            }

            context.Append("}");
        }