public async Task WriteIEnumerableOfIEnumerable()
        {
            IEnumerable input = new List <List <int> >
            {
                new List <int>()
                {
                    1, 2
                },
                new List <int>()
                {
                    3, 4
                }
            };

            string json = await Serializer.SerializeWrapper(input);

            Assert.Equal("[[1,2],[3,4]]", json);

            WrapperForIEnumerable input2 = new WrapperForIEnumerable(new List <object>
            {
                new List <object>()
                {
                    1, 2
                },
                new List <object>()
                {
                    3, 4
                },
            });

            json = await Serializer.SerializeWrapper(input2);

            Assert.Equal("[[1,2],[3,4]]", json);
        }
예제 #2
0
        public static void WriteIEnumerableOfIEnumerable()
        {
            IEnumerable input = new List <List <int> >
            {
                new List <int>()
                {
                    1, 2
                },
                new List <int>()
                {
                    3, 4
                }
            };

            string json = JsonSerializer.Serialize(input);

            Assert.Equal("[[1,2],[3,4]]", json);

            WrapperForIEnumerable input2 = new WrapperForIEnumerable(new List <object>
            {
                new List <object>()
                {
                    1, 2
                },
                new List <object>()
                {
                    3, 4
                },
            });

            json = JsonSerializer.Serialize(input2);
            Assert.Equal("[[1,2],[3,4]]", json);
        }
 // Call only when testing serialization.
 public void Initialize()
 {
     MyIEnumerableWrapper = new WrapperForIEnumerable(new List <object> {
         "Hello"
     });
 }