public static void WriteQueueTOfQueueT() { Queue <Queue <int> > input = new Queue <Queue <int> >(new List <Queue <int> > { new Queue <int>(new List <int>() { 1, 2 }), new Queue <int>(new List <int>() { 3, 4 }) }); string json = JsonSerializer.Serialize(input); Assert.Equal("[[1,2],[3,4]]", json); GenericQueueWrapper <StringQueueWrapper> input2 = new GenericQueueWrapper <StringQueueWrapper>(new List <StringQueueWrapper> { new StringQueueWrapper(new List <string>() { "1", "2" }), new StringQueueWrapper(new List <string>() { "3", "4" }) }); json = JsonSerializer.Serialize(input2); Assert.Equal(@"[[""1"",""2""],[""3"",""4""]]", json); }
public async Task WriteGenericQueueOfQueue() { Queue <Queue> input = new Queue <Queue>(); input.Enqueue(new Queue(new List <int>() { 1, 2 })); input.Enqueue(new Queue(new List <int>() { 3, 4 })); string json = await Serializer.SerializeWrapper(input); Assert.Equal("[[1,2],[3,4]]", json); GenericQueueWrapper <QueueWrapper> input2 = new GenericQueueWrapper <QueueWrapper>(); input2.Enqueue(new QueueWrapper(new List <object>() { 1, 2 })); input2.Enqueue(new QueueWrapper(new List <object>() { 3, 4 })); json = await Serializer.SerializeWrapper(input2); Assert.Equal("[[1,2],[3,4]]", json); }
public static void ReadQueueTOfQueueT() { Queue <Queue <int> > result = JsonSerializer.Deserialize <Queue <Queue <int> > >(Encoding.UTF8.GetBytes(@"[[1,2],[3,4]]")); int expected = 1; foreach (Queue <int> q in result) { foreach (int i in q) { Assert.Equal(expected++, i); } } GenericQueueWrapper <StringQueueWrapper> result2 = JsonSerializer.Deserialize <GenericQueueWrapper <StringQueueWrapper> >(@"[[""1"",""2""],[""3"",""4""]]"); expected = 1; foreach (StringQueueWrapper q in result2) { foreach (string str in q) { Assert.Equal($"{expected++}", str); } } }
public async Task ReadQueueTOfQueueT() { Queue <Queue <int> > result = await Serializer.DeserializeWrapper <Queue <Queue <int> > >(@"[[1,2],[3,4]]"); int expected = 1; foreach (Queue <int> q in result) { foreach (int i in q) { Assert.Equal(expected++, i); } } GenericQueueWrapper <StringQueueWrapper> result2 = await Serializer.DeserializeWrapper <GenericQueueWrapper <StringQueueWrapper> >(@"[[""1"",""2""],[""3"",""4""]]"); expected = 1; foreach (StringQueueWrapper q in result2) { foreach (string str in q) { Assert.Equal($"{expected++}", str); } } }