private static TestDynamicTypeManager GetTestDynamicTypeManager() { TestDynamicTypeManager repo; // clear existing entries if any TestDynamicTypeManager testRepo = new TestDynamicTypeManager(new DynamicTypeDataRepository(), DataSettings.Default); testRepo.DynamicTypeDataRepository.DynamicTypeDescriptorsWhere(d => d.Id > 0).Each(d => testRepo.DynamicTypeDataRepository.Delete(d)); testRepo.DynamicTypeDataRepository.DataInstancesWhere(d => d.Id > 0).Each(d => testRepo.DynamicTypeDataRepository.Delete(d)); // make sure the type isn't in the repo DynamicTypeDescriptor descriptor = testRepo.DynamicTypeDataRepository.DynamicTypeDescriptorsWhere(d => d.Id > 0).FirstOrDefault(); Expect.IsNull(descriptor); repo = testRepo; return(repo); }
public void SaveDescriptorDoesntDuplicte() { TestDynamicTypeManager testRepo = new TestDynamicTypeManager(new DynamicTypeDataRepository(), DataSettings.Default); JObject jobj = (JObject)JsonConvert.DeserializeObject(new { Name = "some name", Arr = new object[] { new { Fromage = "gooey" } } }.ToJson()); Dictionary <object, object> data = jobj.ToObject <Dictionary <object, object> >(); string testTypeName = "test_typeName"; testRepo.DynamicTypeDataRepository.DeleteWhere <DynamicTypeDescriptor>(new { TypeName = testTypeName }); DynamicTypeDescriptor descriptor = testRepo.DynamicTypeDataRepository.DynamicTypeDescriptorsWhere(d => d.TypeName == testTypeName).FirstOrDefault(); Expect.IsNull(descriptor); testRepo.TestSaveTypDescriptor(testTypeName, data); int count = testRepo.DynamicTypeDataRepository.DynamicTypeDescriptorsWhere(d => d.TypeName == testTypeName).Count(); Expect.IsTrue(count == 1); testRepo.TestSaveTypDescriptor(testTypeName, data); count = testRepo.DynamicTypeDataRepository.DynamicTypeDescriptorsWhere(d => d.TypeName == testTypeName).Count(); Expect.IsTrue(count == 1); }
private static void SetupTestData(out TestDynamicTypeManager repo, out Dictionary <object, object> data) { // setup test data JObject jobj = (JObject)JsonConvert.DeserializeObject(new { Name = "some name", ChildObjectProp = new { Name = "child name", ChildProp = "only child has this" }, ChildArrProp = new object[] { new { Fromage = "gooey" } } }.ToJson()); data = jobj.ToObject <Dictionary <object, object> >(); repo = GetTestDynamicTypeManager(); }
public void CanGetClrTypeNameFromArrayOf() { TestDynamicTypeManager testRepo = new TestDynamicTypeManager(new DynamicTypeDataRepository(), DataSettings.Default); testRepo.TestGetClrTypeName(); }