public void can_add_a_parameter_to_a_db_command()
        {
            var serializer = new JsonNetSerializer {
                EnumStorage = EnumStorage.AsString
            };

            var setter = new ContainmentParameterSetter <Target>(serializer, new MemberInfo[] { FindMembers.Member <Target>(x => x.Children) });

            setter.AddElement(new[] { "color" }, FindMembers.Member <Target>(x => x.Color));
            setter.AddElement(new[] { "name" }, FindMembers.Member <Target>(x => x.String));
            setter.AddElement(new[] { "rank" }, FindMembers.Member <Target>(x => x.Number));

            var target = new Target
            {
                Color  = Colors.Blue,
                String = "Ronald McDonald",
                Number = 5
            };

            var command = new NpgsqlCommand();
            var builder = new CommandBuilder(command);

            var parameter = setter.AddParameter(target, builder);

            parameter.NpgsqlDbType.ShouldBe(NpgsqlDbType.Jsonb);
            parameter.Value.ShouldBe("{\"Children\":[{\"color\":\"Blue\",\"name\":\"Ronald McDonald\",\"rank\":5}]}");
        }
        public void can_build_out_the_dictionary()
        {
            var serializer = new JsonNetSerializer {
                EnumStorage = EnumStorage.AsString
            };

            var setter = new ContainmentParameterSetter <Target>(serializer, new MemberInfo[0]);

            setter.AddElement(new [] { "color" }, FindMembers.Member <Target>(x => x.Color));
            setter.AddElement(new [] { "name" }, FindMembers.Member <Target>(x => x.String));
            setter.AddElement(new [] { "rank" }, FindMembers.Member <Target>(x => x.Number));

            var target = new Target
            {
                Color  = Colors.Blue,
                String = "Ronald McDonald",
                Number = 5
            };

            var dict = setter.BuildDictionary(target);

            dict["color"].ShouldBe(Colors.Blue);
            dict["name"].ShouldBe(target.String);
            dict["rank"].ShouldBe(5);
        }
        public void add_element_for_property()
        {
            var property = FindMembers.Member <Target>(x => x.String);

            var setter = new ContainmentParameterSetter <Target>(new JsonNetSerializer(), new MemberInfo[0]);

            setter.AddElement(new[] { "position" }, property);

            setter.Elements[0].Member.Name.ShouldBe(nameof(Target.String));
        }
        public void add_element_for_property()
        {
            var property = FindMembers.Member<Target>(x => x.String);

            var setter = new ContainmentParameterSetter<Target>(new JsonNetSerializer(), new MemberInfo[0]);

            setter.AddElement(new[] { "position" }, property);

            setter.Elements[0].Member.Name.ShouldBe(nameof(Target.String));
        }
        public void can_build_out_the_dictionary()
        {
            var serializer = new JsonNetSerializer {EnumStorage = EnumStorage.AsString};

            var setter = new ContainmentParameterSetter<Target>(serializer, new MemberInfo[0]);

            setter.AddElement(new [] {"color"}, FindMembers.Member<Target>(x => x.Color));
            setter.AddElement(new [] {"name"}, FindMembers.Member<Target>(x => x.String));
            setter.AddElement(new [] {"rank"}, FindMembers.Member<Target>(x => x.Number));

            var target = new Target
            {
                Color = Colors.Blue,
                String = "Ronald McDonald",
                Number = 5
            };

            var dict = setter.BuildDictionary(target);

            dict["color"].ShouldBe(Colors.Blue);
            dict["name"].ShouldBe(target.String);
            dict["rank"].ShouldBe(5);

        }
        public void can_add_a_parameter_to_a_db_command()
        {
            var serializer = new JsonNetSerializer { EnumStorage = EnumStorage.AsString };

            var setter = new ContainmentParameterSetter<Target>(serializer, new MemberInfo[] {FindMembers.Member<Target>(x => x.Children)});

            setter.AddElement(new[] { "color" }, FindMembers.Member<Target>(x => x.Color));
            setter.AddElement(new[] { "name" }, FindMembers.Member<Target>(x => x.String));
            setter.AddElement(new[] { "rank" }, FindMembers.Member<Target>(x => x.Number));

            var target = new Target
            {
                Color = Colors.Blue,
                String = "Ronald McDonald",
                Number = 5
            };

            var command = new NpgsqlCommand();

            var parameter = setter.AddParameter(target, command);

            parameter.NpgsqlDbType.ShouldBe(NpgsqlDbType.Jsonb);
            parameter.Value.ShouldBe("{\"Children\":[{\"color\":\"Blue\",\"name\":\"Ronald McDonald\",\"rank\":5}]}");
        }