当前位置: 首页>>代码示例>>C#>>正文


C# Product.CreateProperty方法代码示例

本文整理汇总了C#中Product.CreateProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Product.CreateProperty方法的具体用法?C# Product.CreateProperty怎么用?C# Product.CreateProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product.CreateProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: when_creating_component_named_as_property_then_throws

        public void when_creating_component_named_as_property_then_throws()
        {
            var product = new Product("Foo", "IFoo");
            product.CreateProperty("Element");

            Assert.Throws<ArgumentException>(() => product.CreateElement("Element", "IElement"));
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:7,代码来源:ComponentModelFixture.cs

示例2: when_visiting_root_then_visits_entire_graph

        public void when_visiting_root_then_visits_entire_graph()
        {
            var products = 0;
            var elements = 0;
            var collections = 0;
            var containers = 0;
            var components = 0;
            var properties = 0;

            var visitor = InstanceVisitor.Create(
                p => products++,
                e => elements++,
                c => collections++,
                c => containers++,
                c => components++,
                p => properties++);

            var product = new Product("Foo", "IFoo");
            product.CreateElement("Element", "IElement")
                .CreateProperty("IsVisible");
            product.CreateCollection("Collection", "ICollection")
                .CreateElement("Element", "IElement");
            product.CreateProperty("IsVisible");

            product.Accept(visitor);

            Assert.Equal(1, products);
            Assert.Equal(2, elements);
            Assert.Equal(1, collections);
            Assert.Equal(4, containers);
            Assert.Equal(4, components);
            Assert.Equal(2, properties);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:33,代码来源:VisitableFixture.cs

示例3: when_mapping_product_then_does_not_remove_underscore_properties

        public void when_mapping_product_then_does_not_remove_underscore_properties()
        {
            var toolkit = new ToolkitSchema("Toolkit", "1.0");
            var schema = toolkit.CreateProductSchema("IProduct");

            var product = new Product("Product", "IProduct");
            product.CreateProperty("_IsVisible").Value = true;

            ComponentMapper.SyncProduct(product, (IProductInfo)schema);

            Assert.NotNull(product.Schema);
            Assert.Equal(1, product.Properties.Count());
            Assert.Equal("_IsVisible", product.Properties.First().Name);
            Assert.True((bool)product.Properties.First().Value);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:15,代码来源:ComponentMapperFixture.cs

示例4: when_creating_property_then_it_has_schema

        public void when_creating_property_then_it_has_schema()
        {
            var product = new Product("Foo", "IFoo");
            var info = Mock.Of<IProductInfo>(x =>
                x.Toolkit.Id == "Test" &&
                x.Toolkit.Version == "1.0" &&
                x.SchemaId == "IFoo" &&
                x.Properties == new []
                {
                    Mock.Of<IPropertyInfo>(p => p.Name == "IsPublic" && p.PropertyType == typeof(bool))
                });

            product.Schema = info;

            var prop = product.CreateProperty("IsPublic");

            Assert.NotNull(prop.Schema);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:18,代码来源:ComponentModelFixture.cs

示例5: when_property_set_to_same_existing_value_then_does_not_raise_propertychanged

        public void when_property_set_to_same_existing_value_then_does_not_raise_propertychanged()
        {
            var product = new Product("Product", "IProduct");
            product.CreateProperty("key").Value = "foo";

            var changed = default(PropertyChangeEventArgs);

            product.Events.PropertyChanged += (sender, args) => changed = args;

            product.Set("key", "foo");

            Assert.Null(changed);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:13,代码来源:ComponentModelFixture.cs

示例6: when_property_changing_then_notifies_component

        public void when_property_changing_then_notifies_component()
        {
            var product = new Product("Product", "IProduct");
            product.CreateProperty("key").Value = "foo";

            var changing = default(PropertyChangeEventArgs);

            product.Events.PropertyChanging += (sender, args) => changing = args;

            product.Set("key", "bar");

            Assert.NotNull(changing);
            Assert.Equal("key", changing.PropertyName);
            Assert.Equal("foo", changing.OldValue);
            Assert.Equal("bar", changing.NewValue);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:16,代码来源:ComponentModelFixture.cs

示例7: when_element_new_name_is_duplicated_with_container_property_then_throws

        public void when_element_new_name_is_duplicated_with_container_property_then_throws()
        {
            var product = new Product("Foo", "IFoo");
            product.CreateProperty("Element");

            var child = product.CreateElement("Storage", "IStorage");

            Assert.Throws<ArgumentException>(() => child.Name = "Element");
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:9,代码来源:ComponentModelFixture.cs

示例8: when_deleting_property_then_removes_from_owner

        public void when_deleting_property_then_removes_from_owner()
        {
            var product = new Product("Foo", "IFoo");
            var prop = product.CreateProperty("IsPublic");

            prop.Delete();

            Assert.Equal(0, product.Properties.Count());
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:9,代码来源:ComponentModelFixture.cs

示例9: when_deleting_property_then_owner_becomes_null

        public void when_deleting_property_then_owner_becomes_null()
        {
            var product = new Product("Foo", "IFoo");
            var prop = product.CreateProperty("IsPublic");

            prop.Delete();

            Assert.Null(prop.Owner);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:9,代码来源:ComponentModelFixture.cs

示例10: when_creating_property_then_owner_properties_contains_new_property

        public void when_creating_property_then_owner_properties_contains_new_property()
        {
            var product = new Product("Foo", "IFoo");

            var prop = product.CreateProperty("IsPublic");

            Assert.Same(prop, product.Properties.FirstOrDefault());
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:8,代码来源:ComponentModelFixture.cs

示例11: when_creating_property_then_owner_is_parent

        public void when_creating_property_then_owner_is_parent()
        {
            var product = new Product("Foo", "IFoo");

            var prop = product.CreateProperty("IsPublic");

            Assert.Same(product, prop.Owner);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:8,代码来源:ComponentModelFixture.cs

示例12: when_creating_name_property_then_throws_because_its_intrinsic

        public void when_creating_name_property_then_throws_because_its_intrinsic()
        {
            var product = new Product("Foo", "IFoo");

            Assert.Throws<ArgumentException>(() => product.CreateProperty("Name"));
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:6,代码来源:ComponentModelFixture.cs

示例13: when_creating_duplicate_property_then_throws

        public void when_creating_duplicate_property_then_throws()
        {
            var product = new Product("Foo", "IFoo");
            var prop = product.CreateProperty("IsPublic");

            Assert.Throws<ArgumentException>(() => product.CreateProperty("IsPublic"));
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:7,代码来源:ComponentModelFixture.cs

示例14: when_mapping_product_then_maps_property_schema

        public void when_mapping_product_then_maps_property_schema()
        {
            var toolkit = new ToolkitSchema("Toolkit", "1.0");
            var schema = toolkit.CreateProductSchema("IProduct");
            schema.CreatePropertySchema("IsPublic", typeof(bool));

            var product = new Product("Product", "IProduct");
            product.CreateProperty("IsPublic").Value = true;

            ComponentMapper.SyncProduct(product, (IProductInfo)schema);

            Assert.NotNull(product.Schema);
            Assert.NotNull(product.Properties.First().Schema);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:14,代码来源:ComponentMapperFixture.cs

示例15: when_mapping_product_then_removes_properties_that_dont_exist_in_schema

        public void when_mapping_product_then_removes_properties_that_dont_exist_in_schema()
        {
            var toolkit = new ToolkitSchema("Toolkit", "1.0");
            var schema = toolkit.CreateProductSchema("IProduct");
            schema.CreatePropertySchema("IsPublic", typeof(bool));

            var product = new Product("Product", "IProduct");
            product.CreateProperty("IsVisible").Value = true;

            ComponentMapper.SyncProduct(product, (IProductInfo)schema);

            Assert.NotNull(product.Schema);
            Assert.Equal(1, product.Properties.Count());
            Assert.Equal("IsPublic", product.Properties.First().Name);
            Assert.False((bool)product.Properties.First().Value);
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:16,代码来源:ComponentMapperFixture.cs


注:本文中的Product.CreateProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。