Exemple #1
0
        public void Clone_ShouldReturnNull_GivenNull()
        {
            var options  = new JsonSerializerOptions();
            var target   = options.CreateCloner();
            var expected = default(TestClass);

            var actual = target.Clone(expected);

            Assert.Null(actual);
        }
Exemple #2
0
        public void Clone_ShouldDeepClone_GivenNonNull()
        {
            var options  = new JsonSerializerOptions();
            var target   = options.CreateCloner();
            var expected = TestClass.Random();

            var actual = target.Clone(expected);

            Assert.Equal(expected, actual);
            Assert.NotSame(expected, actual);
        }
        public void Run()
        {
            var options = new JsonSerializerOptions();

            // Setup options your way.

            var cloner = options.CreateCloner();

            var original = new Point {
                X = 10, Y = 53
            };
            var clone = cloner.Clone(original);

            Console.WriteLine($"Original: {original}");
            Console.WriteLine($"Clone: {clone}");
            Console.WriteLine(object.ReferenceEquals(original, clone));
        }