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());
        }
Example #3
0
 public void Initialize()
 {
     MyStringICollectionWrapper = new StringICollectionWrapper()
     {
         "Hello"
     };
     MyStringIListWrapper = new StringIListWrapper()
     {
         "Hello"
     };
     MyStringISetWrapper = new StringISetWrapper()
     {
         "Hello"
     };
     MyStringToStringIDictionaryWrapper = new StringToStringIDictionaryWrapper()
     {
         { "key", "value" }
     };
     MyStringListWrapper = new StringListWrapper()
     {
         "Hello"
     };
     MyStringStackWrapper = new StringStackWrapper(new List <string> {
         "Hello"
     });
     MyStringQueueWrapper = new StringQueueWrapper(new List <string> {
         "Hello"
     });
     MyStringHashSetWrapper = new StringHashSetWrapper()
     {
         "Hello"
     };
     MyStringLinkedListWrapper = new StringLinkedListWrapper(new List <string> {
         "Hello"
     });
     MyStringSortedSetWrapper = new StringSortedSetWrapper()
     {
         "Hello"
     };
     MyStringToStringDictionaryWrapper = new StringToStringDictionaryWrapper()
     {
         { "key", "value" }
     };
     MyStringToStringSortedDictionaryWrapper = new StringToStringSortedDictionaryWrapper()
     {
         { "key", "value" }
     };
     MyStringToGenericDictionaryWrapper = new StringToGenericDictionaryWrapper <StringToGenericDictionaryWrapper <string> >()
     {
         { "key", new StringToGenericDictionaryWrapper <string>()
           {
               { "key", "value" }
           } }
     };
 }