コード例 #1
0
        public static void ReadSimpleGenericIList()
        {
            IList <int> result   = JsonSerializer.Deserialize <IList <int> >(Encoding.UTF8.GetBytes(@"[1,2]"));
            int         expected = 1;

            foreach (int i in result)
            {
                Assert.Equal(expected++, i);
            }

            result = JsonSerializer.Deserialize <IList <int> >(Encoding.UTF8.GetBytes(@"[]"));
            Assert.Equal(0, result.Count());

            StringIListWrapper result2 = JsonSerializer.Deserialize <StringIListWrapper>(@"[""1"",""2""]");

            expected = 1;

            foreach (string str in result2)
            {
                Assert.Equal($"{expected++}", str);
            }

            result2 = JsonSerializer.Deserialize <StringIListWrapper>(@"[]");
            Assert.Equal(0, result2.Count());
        }
コード例 #2
0
        public async Task ReadSimpleGenericIList()
        {
            IList <int> result = await Serializer.DeserializeWrapper <IList <int> >(@"[1,2]");

            int expected = 1;

            foreach (int i in result)
            {
                Assert.Equal(expected++, i);
            }

            result = await Serializer.DeserializeWrapper <IList <int> >(@"[]");

            Assert.Equal(0, result.Count());

            StringIListWrapper result2 = await Serializer.DeserializeWrapper <StringIListWrapper>(@"[""1"",""2""]");

            expected = 1;

            foreach (string str in result2)
            {
                Assert.Equal($"{expected++}", str);
            }

            result2 = await Serializer.DeserializeWrapper <StringIListWrapper>(@"[]");

            Assert.Equal(0, result2.Count());
        }
コード例 #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" }
           } }
     };
 }