public void GivenErrorHandlingStrategy_WhenBreakPopulate_Breaks()
        {
            CustomizableErrorHandlingStrategy errorStrategy = new CustomizableErrorHandlingStrategy
            {
                PrePopulateAction = (json, o) => json.Contains("test")
                    ? new PreviewResult()
                {
                    BreakPopulating = true
                }
                    : new PreviewResult()
                {
                    BreakPopulating = false
                }
            };

            strategy.ErrorStrategy = errorStrategy;

            {
                string s = "test, this is an invalid json that should throw exception, unless populating is skipped";
                {
                    T1 t1 = new T1();
                    strategy.PopulateFromSerialized(t1, s);
                    Expect(t1.D1, Null);
                    Expect(t1.D2, False);
                }
            }

            {
                string s  = "this is also invalid json, but doesn't match skip condition, thus should cause exception";
                T1     t1 = new T1();
                Assert.Throws <JsonReaderException>(() => strategy.PopulateFromSerialized(t1, s));
            }
        }
        public void GivenErrorHandlingStrategy_WhenUnparseableValue_CanBeIgnored()
        {
            CustomizableErrorHandlingStrategy errorStrategy = new CustomizableErrorHandlingStrategy
            {
                DeserializeErrorAction = (o, args) => args.ErrorContext.Handled = true,
                SerializeErrorAction   = (o, args) => args.ErrorContext.Handled = true
            };

            strategy.ErrorStrategy = errorStrategy;

            string s;

            {
                T1 t1 = new T1();
                t1.D1 = "123";
                t1.D2 = true;
                s     = strategy.Serialize(t1);
            }
            s = s.Replace(@"""d2"": true", @"""d2"": ""123""");
            {
                T1 t1 = new T1();
                strategy.PopulateFromSerialized(t1, s);
                Expect(t1.D1, EqualTo("123"));
                Expect(t1.D2, False);
            }
        }