コード例 #1
0
        public void convert_simple_type_with_null()
        {
            var sample = new MyType1 {
                Region = null
            };
            var expected = @$ "{{" "Region" ":null}}";

            var json = JsonSerializer.Serialize(sample, SerOptions);
            var inst = JsonSerializer.Deserialize <MyType1>(json, SerOptions);

            Assert.Equal(expected, json);
            Assert.Equal(sample.Region, inst.Region);
        }
コード例 #2
0
        public void convert_simple_type_with_value()
        {
            var sample = new MyType1 {
                Region = CloudWatchRegion.AfSouth1
            };
            var expected = @$ "{{" "Region" ":" "{CloudWatchRegion.AfSouth1}" "}}";

            var json = JsonSerializer.Serialize(sample, SerOptions);
            var inst = JsonSerializer.Deserialize <MyType1>(json, SerOptions);

            Assert.Equal(expected, json);
            Assert.Equal(sample.Region, inst.Region);
            Assert.Equal(sample.Region.Value, inst.Region.Value);
        }
コード例 #3
0
        public void MapTwoTrackFunction_OfSome_MapsToNewSome()
        {
            Option <MyType1> option = new MyType1();

            Option <string> result = option.Map(mt => mt.ToString().NoneIfNull());

            if (result is Some <string> some)
            {
                Assert.AreEqual(nameof(MyType1), some.Content);
            }
            else
            {
                Assert.Fail();
            }
        }