Esempio n. 1
0
 public void Registration()
 {
     ImportContext context = new ImportContext();
     ThingImporter importer = new ThingImporter();
     context.Register(importer);
     Assert.AreSame(importer, context.FindImporter(typeof(Thing)));
 }
Esempio n. 2
0
 public void RegistrationIsPerContext()
 {
     ImportContext context = new ImportContext();
     ThingImporter exporter = new ThingImporter();
     context.Register(exporter);
     context = new ImportContext();
     Assert.AreNotSame(exporter, context.FindImporter(typeof(Thing)));
 }
Esempio n. 3
0
        public void Registration()
        {
            ImportContext context  = new ImportContext();
            ThingImporter importer = new ThingImporter();

            context.Register(importer);
            Assert.AreSame(importer, context.FindImporter(typeof(Thing)));
        }
Esempio n. 4
0
        public void RegistrationIsPerContext()
        {
            ImportContext context  = new ImportContext();
            ThingImporter exporter = new ThingImporter();

            context.Register(exporter);
            context = new ImportContext();
            Assert.AreNotSame(exporter, context.FindImporter(typeof(Thing)));
        }
Esempio n. 5
0
        private static object Import(bool hasValue, string input)
        {
            JsonReader    reader        = JsonText.CreateReader(input);
            ImportContext context       = JsonConvert.CreateImportContext();
            ThingImporter thingImporter = new ThingImporter();

            context.Register(thingImporter);
            NullableImporter importer = new NullableImporter(typeof(Thing?));
            object           thing    = importer.Import(context, reader);

            Assert.AreEqual(hasValue, thingImporter.ImportCalled);
            if (hasValue)
            {
                Assert.IsInstanceOfType(typeof(Thing), thing);
            }
            else
            {
                Assert.IsNull(thing);
            }
            Assert.IsTrue(reader.EOF, "Reader must be at EOF.");
            return(thing);
        }
Esempio n. 6
0
 private static object Import(bool hasValue, string input)
 {
     JsonReader reader = JsonText.CreateReader(input);
     ImportContext context = JsonConvert.CreateImportContext();
     ThingImporter thingImporter = new ThingImporter();
     context.Register(thingImporter);
     NullableImporter importer = new NullableImporter(typeof(Thing?));
     object thing = importer.Import(context, reader);
     Assert.AreEqual(hasValue, thingImporter.ImportCalled);
     if (hasValue)
         Assert.IsInstanceOfType(typeof(Thing), thing);
     else
         Assert.IsNull(thing);
     Assert.IsTrue(reader.EOF, "Reader must be at EOF.");
     return thing;
 }