public void SetCurrentImportContextFactory() { try { ImportContextFactoryHandler factory = new ImportContextFactoryHandler(CreateImportContext); JsonConvert.CurrentImportContextFactory = factory; Assert.AreSame(factory, JsonConvert.CurrentImportContextFactory); JsonConvert.CreateImportContext(); Assert.IsTrue(_createImportContextCalled); } finally { JsonConvert.CurrentImportContextFactory = JsonConvert.DefaultImportContextFactory; } }
public void SetCurrentImportContextFactory() { try { var called = false; Func <ImportContext> factory = () => { called = true; return(null); }; JsonConvert.CurrentImportContextFactory = factory; Assert.AreSame(factory, JsonConvert.CurrentImportContextFactory); JsonConvert.CreateImportContext(); Assert.IsTrue(called); } finally { JsonConvert.CurrentImportContextFactory = JsonConvert.DefaultImportContextFactory; } }