public static void ReadSimpleGenericStack() { Stack <int> result = JsonSerializer.Deserialize <Stack <int> >(Encoding.UTF8.GetBytes(@"[1,2]")); int expected = 2; foreach (int i in result) { Assert.Equal(expected--, i); } result = JsonSerializer.Deserialize <Stack <int> >(Encoding.UTF8.GetBytes(@"[]")); Assert.Equal(0, result.Count()); StringStackWrapper result2 = JsonSerializer.Deserialize <StringStackWrapper>(@"[""1"",""2""]"); expected = 2; foreach (string str in result2) { Assert.Equal($"{expected--}", str); } result2 = JsonSerializer.Deserialize <StringStackWrapper>(@"[]"); Assert.Equal(0, result2.Count()); }
public async Task ReadSimpleGenericStack() { Stack <int> result = await Serializer.DeserializeWrapper <Stack <int> >(@"[1,2]"); int expected = 2; foreach (int i in result) { Assert.Equal(expected--, i); } result = await Serializer.DeserializeWrapper <Stack <int> >(@"[]"); Assert.Equal(0, result.Count()); StringStackWrapper result2 = await Serializer.DeserializeWrapper <StringStackWrapper>(@"[""1"",""2""]"); expected = 2; foreach (string str in result2) { Assert.Equal($"{expected--}", str); } result2 = await Serializer.DeserializeWrapper <StringStackWrapper>(@"[]"); Assert.Equal(0, result2.Count()); }