本文整理汇总了C#中Product.CreateCollection方法的典型用法代码示例。如果您正苦于以下问题:C# Product.CreateCollection方法的具体用法?C# Product.CreateCollection怎么用?C# Product.CreateCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.CreateCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: when_creating_collection_item_then_can_access_product
public void when_creating_collection_item_then_can_access_product()
{
var product = new Product("Product", "IProduct");
var collection = product.CreateCollection("Collection", "ICollection");
var item = collection.CreateItem("Item", "IItem");
Assert.Same(product, item.Product);
}
示例3: when_creating_collection_then_references_parent_product
public void when_creating_collection_then_references_parent_product()
{
var product = new Product("Foo", "IFoo");
var child = product.CreateCollection("Buckets", "IBuckets");
Assert.Same(child.Parent, product);
}
示例4: when_creating_collection_then_sets_name_and_schema_id
public void when_creating_collection_then_sets_name_and_schema_id()
{
var product = new Product("Foo", "IFoo");
var child = product.CreateCollection("Buckets", "IBuckets");
Assert.Equal("Buckets", child.Name);
Assert.Equal("IBuckets", child.SchemaId);
}
示例5: when_creating_collection_item_then_can_access_it
public void when_creating_collection_item_then_can_access_it()
{
var product = new Product("Product", "IProduct");
var collection = product.CreateCollection("Collection", "ICollection");
var item = collection.CreateItem("Item", "IItem");
Assert.Equal(1, collection.Items.Count());
Assert.Same(item, collection.Items.First());
}
示例6: when_creating_collection_item_then_raises_item_added
public void when_creating_collection_item_then_raises_item_added()
{
var product = new Product("Product", "IProduct");
var collection = product.CreateCollection("Collection", "ICollection");
var item = default(IElement);
collection.ItemAdded += (sender, args) => item = args.Value;
var created = collection.CreateItem("Item", "IItem");
Assert.NotNull(item);
Assert.Same(created, item);
}
示例7: when_mapping_product_then_maps_collection_item_schema
public void when_mapping_product_then_maps_collection_item_schema()
{
var toolkit = new ToolkitSchema("Toolkit", "1.0");
var schema = toolkit.CreateProductSchema("IProduct");
var collection = schema.CreateCollectionSchema("ICollection");
var item = collection.CreateItemSchema("IElement");
item.CreatePropertySchema("IsPublic", typeof(bool));
var product = new Product("Product", "IProduct");
product.CreateCollection("Collection", "ICollection")
.CreateItem("Element", "IElement")
.CreateProperty("IsPublic").Value = true;
ComponentMapper.SyncProduct(product, (IProductInfo)schema);
Assert.NotNull(product.Components.First().Schema);
Assert.NotNull(product.Components.OfType<ICollection>().First().Items.First().Schema);
Assert.NotNull(product.Components.OfType<ICollection>().First().Items.First().Properties.First().Schema);
}
示例8: when_creating_duplicate_name_component_then_throws
public void when_creating_duplicate_name_component_then_throws()
{
var product = new Product("Foo", "IFoo");
var child = product.CreateCollection("Storage", "IStorage");
// Same name and schema id
Assert.Throws<ArgumentException>(() => product.CreateCollection("Storage", "IStorage"));
// Same name, different schema id
Assert.Throws<ArgumentException>(() => product.CreateCollection("Storage", "IBucket"));
// Different component type, same name and schema id
Assert.Throws<ArgumentException>(() => product.CreateElement("Storage", "IStorage"));
// Different component type, same name, different schema id
Assert.Throws<ArgumentException>(() => product.CreateElement("Storage", "IBucket"));
}
示例9: when_creating_duplicate_name_collection_item_then_throws
public void when_creating_duplicate_name_collection_item_then_throws()
{
var product = new Product("Product", "IProduct");
var collection = product.CreateCollection("Collection", "ICollection");
var item = collection.CreateItem("Item", "IItem");
Assert.Throws<ArgumentException>(() => collection.CreateItem("Item", "IItem"));
}
示例10: when_creating_collection_then_it_has_schema
public void when_creating_collection_then_it_has_schema()
{
var info = Mock.Of<IProductInfo>(x =>
x.Toolkit.Id == "Test" &&
x.Toolkit.Version == "1.0" &&
x.SchemaId == "IFoo" &&
x.Components == new IComponentInfo[]
{
Mock.Of<ICollectionInfo>(e =>
e.SchemaId == "ICollection" &&
e.Item == Mock.Of<IElementInfo>(i => i.SchemaId == "IElement"))
});
var product = new Product("Foo", "IFoo");
product.Schema = info;
var child = product.CreateCollection("Buckets", "ICollection");
Assert.NotNull(child.Schema);
}
示例11: when_property_changed_on_collection_item_then_raises_property_changed_on_parent
public void when_property_changed_on_collection_item_then_raises_property_changed_on_parent()
{
var product = new Product("Product", "IProduct");
product
.CreateCollection("Collection", "ICollection")
.CreateItem("Item", "IItem")
.CreateProperty("key").Value = "foo";
var changed = default(PropertyChangeEventArgs);
product.Events.PropertyChanged += (sender, args) => changed = args;
product.Components.OfType<ICollection>().First().Items.First().Set("key", "bar");
Assert.NotNull(changed);
Assert.Equal("Collection", changed.PropertyName);
Assert.Same(changed.OldValue, changed.NewValue);
Assert.Same(product.Components.First(), changed.NewValue);
}
示例12: when_enumerating_components_then_can_access_created_collection
public void when_enumerating_components_then_can_access_created_collection()
{
var product = new Product("Foo", "IFoo");
var child = product.CreateCollection("Buckets", "IBuckets");
var component = product.Components.FirstOrDefault();
Assert.NotNull(component);
Assert.Same(child, component);
}
示例13: when_disposing_product_then_disposes_entire_graph
public void when_disposing_product_then_disposes_entire_graph()
{
var product = new Product("Product", "IProduct");
product.CreateCollection("Collection", "ICollection")
.CreateItem("Item", "IItem");
product.CreateElement("Element", "IElement")
.CreateElement("NestedElement", "IElement");
product.Dispose();
Assert.True(product.IsDisposed);
Assert.True(product.Components.All(c => c.IsDisposed));
Assert.True(product.Components.OfType<Collection>().All(c => c.Items.All(e => e.IsDisposed)));
}
示例14: when_deleting_collection_item_then_removes_from_parent_collection
public void when_deleting_collection_item_then_removes_from_parent_collection()
{
var product = new Product("Foo", "IFoo");
var collection = product.CreateCollection("Collection", "ICollection");
var child = collection.CreateItem("Item", "IItem");
child.Delete();
Assert.Equal(0, collection.Items.Count());
}
示例15: when_deleting_collection_item_then_raises_item_deleted
public void when_deleting_collection_item_then_raises_item_deleted()
{
var product = new Product("Foo", "IFoo");
var collection = product.CreateCollection("Collection", "ICollection");
var child = collection.CreateItem("Item", "IItem");
var deleted = default(IElement);
collection.ItemRemoved += (sender, args) => deleted = args.Value;
child.Delete();
Assert.NotNull(deleted);
Assert.Same(child, deleted);
}