public void ISet()
        {
            const string   hexBuffer = "A16A436F6C6C656374696F6E820C0D";
            ObjectWithISet obj       = Helper.Read <ObjectWithISet>(hexBuffer);

            Assert.NotNull(obj);
            Assert.NotNull(obj.Collection);
            Assert.IsType <HashSet <int> >(obj.Collection);
            Assert.Equal(2, obj.Collection.Count);
            Assert.Equal(12, obj.Collection.ElementAt(0));
            Assert.Equal(13, obj.Collection.ElementAt(1));

            Helper.TestWrite(obj, hexBuffer);
        }
Ejemplo n.º 2
0
        public void ISet()
        {
            JsonSerializerOptions options = new JsonSerializerOptions();

            options.SetupExtensions();

            const string   json = @"{""Collection"":[12,13]}";
            ObjectWithISet obj  = JsonSerializer.Deserialize <ObjectWithISet>(json, options);

            Assert.NotNull(obj);
            Assert.NotNull(obj.Collection);
            Assert.IsType <HashSet <int> >(obj.Collection);
            Assert.Equal(2, obj.Collection.Count);
            Assert.Equal(12, obj.Collection.ElementAt(0));
            Assert.Equal(13, obj.Collection.ElementAt(1));

            string actual = JsonSerializer.Serialize(obj, obj.GetType(), options);

            Assert.Equal(json, actual);
        }