Ejemplo n.º 1
0
        public void CanAddType()
        {
            DynamicTypeManager    mgr            = new DynamicTypeManager(new DynamicTypeDataRepository(), DataSettings.Default);
            string                testType       = "CanAddTypeTest";
            DynamicTypeDescriptor typeDescriptor = mgr.GetTypeDescriptor(testType);

            Expect.IsNull(typeDescriptor, "typeDescriptor should have been null");
            typeDescriptor = mgr.AddType(testType);
            Expect.IsNotNull(typeDescriptor, "typeDescriptor should NOT have been null");
            typeDescriptor = mgr.GetTypeDescriptor(testType);
            Expect.IsNotNull(typeDescriptor, "typeDescriptor should NOT have been null");
            OutLineFormat("{0}", typeDescriptor.PropertiesToString());
        }
Ejemplo n.º 2
0
        public void CanAddPropertyToType()
        {
            DynamicTypeManager mgr = new DynamicTypeManager(new DynamicTypeDataRepository(), DataSettings.Default);

            mgr.DynamicTypeDataRepository.Query <DynamicTypeDescriptor>(d => d.Id > 0).Each(d => mgr.DynamicTypeDataRepository.Delete(d));
            mgr.DynamicTypeDataRepository.Query <DynamicTypePropertyDescriptor>(p => p.Id > 0).Each(p => mgr.DynamicTypeDataRepository.Delete(p));
            string testType      = nameof(CanAddPropertyToType);
            string testProperty  = "SomeProperty";
            string testProperty2 = "BooleanProperty";

            mgr.AddType(testType);
            DynamicTypePropertyDescriptor prop  = mgr.AddProperty(testType, testProperty, "String");
            DynamicTypePropertyDescriptor prop2 = mgr.AddProperty(testType, testProperty2, "Boolean");

            Expect.IsNotNull(prop);
            DynamicTypeDescriptor typeDescriptor = mgr.GetTypeDescriptor(testType);

            Expect.IsNotNull(typeDescriptor);
            Expect.IsTrue(typeDescriptor.Properties.Count == 2);
        }