Example #1
0
        public static void ReadPrimitiveIImmutableQueueT()
        {
            IImmutableQueue <int> result = JsonSerializer.Parse <IImmutableQueue <int> >(Encoding.UTF8.GetBytes(@"[1,2]"));
            int expected = 1;

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

            result = JsonSerializer.Parse <IImmutableQueue <int> >(Encoding.UTF8.GetBytes(@"[]"));
            Assert.Equal(0, result.Count());
        }
        public void DeserializeQueueInterface()
        {
            string json = @"[
  ""One"",
  ""II"",
  ""3""
]";

            IImmutableQueue <string> l = JsonConvert.DeserializeObject <IImmutableQueue <string> >(json);

            Assert.AreEqual(3, l.Count());
            Assert.AreEqual("One", l.ElementAt(0));
            Assert.AreEqual("II", l.ElementAt(1));
            Assert.AreEqual("3", l.ElementAt(2));
        }
        public static void ReadPrimitiveIImmutableQueueT()
        {
            IImmutableQueue <int> result = JsonSerializer.Deserialize <IImmutableQueue <int> >(Encoding.UTF8.GetBytes(@"[1,2]"));
            int expected = 1;

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

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

            Assert.Throws <JsonException>(() => JsonSerializer.Deserialize <StringIImmutableQueueWrapper>(@"[""1"",""2""]"));
            Assert.Throws <JsonException>(() => JsonSerializer.Deserialize <StringIImmutableQueueWrapper>(@"[]"));
        }
Example #4
0
        public async Task ReadPrimitiveIImmutableQueueT()
        {
            IImmutableQueue <int> result = await JsonSerializerWrapperForString.DeserializeWrapper <IImmutableQueue <int> >(@"[1,2]");

            int expected = 1;

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

            result = await JsonSerializerWrapperForString.DeserializeWrapper <IImmutableQueue <int> >(@"[]");

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

            await Assert.ThrowsAsync <NotSupportedException>(async() => await JsonSerializerWrapperForString.DeserializeWrapper <StringIImmutableQueueWrapper>(@"[""1"",""2""]"));

            await Assert.ThrowsAsync <NotSupportedException>(async() => await JsonSerializerWrapperForString.DeserializeWrapper <StringIImmutableQueueWrapper>(@"[]"));
        }
 public void Dispose()
 {
     Console.WriteLine("Stream disposed, Buffer count: " + buffer.Count());
 }