本文整理汇总了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"));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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"));
}
示例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"));
}
示例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);
}
示例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);
}