Exemplo n.º 1
0
        public void JsonExtensions_Annonymous_FromList()
        {
            var expectedResult           = new JArray(ExpectedJsonResult);
            var mockAnonnymousObjectList = new List <dynamic> {
                new { Foo = ExpectedFoo, Arr = ExpectedArr }
            };

            var result = JsonExtensions.FromList <object>(mockAnonnymousObjectList);

            Assert.Equal(result, expectedResult);
        }
Exemplo n.º 2
0
        public void JsonExtensions_Typed_FromList()
        {
            var expectedResult = new JArray(ExpectedJsonResult);
            IList <MockType> mockTypedObject = new List <MockType> {
                new MockType()
                {
                    Foo = ExpectedFoo,
                    Arr = ExpectedArr
                }
            };

            var result = JsonExtensions.FromList <MockType>(mockTypedObject);

            Assert.Equal(result, expectedResult);
        }
Exemplo n.º 3
0
        public static Response FromList <T>(IList <T> results, ResponseStatus status = ResponseStatus.OK) where T : new()
        {
            var serializedResults = JsonExtensions.FromList(results);

            return(new Response(serializedResults, status));
        }