public IEntity RunTest(string json, ApiResourceMapping mapping, ReaderToEntityAdapterSettings settings = null) { if (json != null) { json = json.Replace("'", @""""); } // Get dynamic object from JSON object raw = JilHelpers.Deserialize <object>(json); Assert.That(raw, Is.InstanceOf <IDynamicMetaObjectProvider>( ), "Dynamic object should be IDynamicMetaObjectProvider"); IDynamicMetaObjectProvider dynamicProvider = ( IDynamicMetaObjectProvider )raw; // Get object reader IDynamicObjectReaderService objectReaderService = Factory.Current.Resolve <IDynamicObjectReaderService>( ); IObjectReader reader = objectReaderService.GetObjectReader(dynamicProvider); // Settings ReaderToEntityAdapterSettings settingsToUse = settings ?? new ReaderToEntityAdapterSettings(); // Run adapter provider IReaderToEntityAdapterProvider adapterProvider = Factory.Current.Resolve <IReaderToEntityAdapterProvider>( ); IReaderToEntityAdapter adapter = adapterProvider.GetAdapter(mapping.Id, settingsToUse); IEntity entity = adapter.CreateEntity(reader, ConnectorRequestExceptionReporter.Instance); return(entity); }
static IDynamicMetaObjectProvider GetDynamicProvider(string json, IResolveConstraint constraint = null) { if (json != null) { json = json.Replace("'", @""""); } object raw = JilHelpers.Deserialize <object>(json); if (constraint != null) { Assert.That(raw, constraint); } else { Assert.That(raw, Is.InstanceOf <IDynamicMetaObjectProvider>( )); } IDynamicMetaObjectProvider dynamicProvider = ( IDynamicMetaObjectProvider )raw; return(dynamicProvider); }