예제 #1
0
        public void ParamMangler2()
        {
            IQueryParamentersMangler parameterMangler = new DefaultParameterMangler();

            var result = parameterMangler.Mangle(new
            {
                value = new
                {
                    DateTime         = new DateTime(1234, 1, 2),
                    DateTimeNullable = (DateTimeOffset?)null,
                    GuidValue        = Guid.NewGuid(),
                    ValuesInt        = new List <int>()
                    {
                        1, 2, 3
                    },
                    ValuesObject = new List <object>()
                    {
                        new object()
                    }
                }
            });

            IDictionary <string, object> value = result["value"] as IDictionary <string, object>;

            Assert.Equal(((DateTimeOffset) new DateTime(1234, 1, 2)).ToUnixTimeMilliseconds(), value["DateTime"]);
            Assert.Null(value["DateTimeNullable"]);
            Assert.NotEqual(default(Guid), value["GuidValue"]);
            Assert.Equal(new List <int>()
            {
                1, 2, 3
            }, value["ValuesInt"]);
            Assert.True(value.ContainsKey("ValuesObject"));
            Assert.True(value["ValuesObject"] is List <object>);
            Assert.True(((List <object>)value["ValuesObject"])[0] is IDictionary <string, object>);
        }
예제 #2
0
        public void DeafultParamMangler()
        {
            DefaultParameterMangler obj = new DefaultParameterMangler();

            var result = obj.Mangle(new { rows = new List <object>()
                                          {
                                              new { X = 0, Y = 0 }, new { X = 1, Y = 1 }
                                          } });
        }
예제 #3
0
        public void ParamMangler()
        {
            IQueryParamentersMangler parameterMangler = new DefaultParameterMangler();

            var result = parameterMangler.Mangle(new { val = 1, lst = new List <object>()
                                                       {
                                                           new { Name = "x" }, new { Name = "y" }, new { Name = Guid.NewGuid() }
                                                       } });

            Assert.Equal(1, result["val"]);
            Assert.Equal(3, ((List <object>)result["lst"]).Count);
            Assert.Equal("x", ((IDictionary <string, object>)((List <object>)result["lst"])[0])["Name"]);
            Assert.Equal("y", ((IDictionary <string, object>)((List <object>)result["lst"])[1])["Name"]);
            Assert.IsType <string>(((IDictionary <string, object>)((List <object>)result["lst"])[2])["Name"]);

            var user = parameterMangler.Mangle(new { user = new Dictionary <string, object>()
                                                     {
                                                         { "Name", "Luca" }, { "Age", 33 }
                                                     } });

            Assert.Equal("Luca", ((IDictionary <string, object>)user["user"])["Name"]);
            Assert.Equal(33, ((IDictionary <string, object>)user["user"])["Age"]);
        }