Example #1
0
        public void CanAggregateIntoImmutableHashSet()
        {
            ImmutableHashSet <int> set = from i in INT_SOURCE
                                         orderby Distinct
                                         group i by ToImmutableHashSet into s
                                         select s;

            set.GetType().Should().Be <ImmutableHashSet <int> >();
        }
        public void WriteImmutableHashSetOfInt32()
        {
            ImmutableHashSet <int> value    = ImmutableHashSet.CreateRange(new[] { 1, 2, 3 });
            const string           expected = "[1,2,3]";

            JsonSerializerOptions options = new JsonSerializerOptions();

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

            Assert.Equal(expected, actual);
        }