本文整理汇总了C#中Root.Invoking方法的典型用法代码示例。如果您正苦于以下问题:C# Root.Invoking方法的具体用法?C# Root.Invoking怎么用?C# Root.Invoking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Root
的用法示例。
在下文中一共展示了Root.Invoking方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Createing_nested_entities_works_and_events_dispatch_correctly
public void Createing_nested_entities_works_and_events_dispatch_correctly()
{
var root = new Root("root");
var entity1 = root.AddEntity("entity1");
entity1.Name.Should().Be("entity1");
root.Entities.InCreationOrder.Count.Should().Be(1);
root.Entities.Exists(entity1.Id).Should().Be(true);
root.Entities.Get(entity1.Id).Should().Be(entity1);
root.Entities[entity1.Id].Should().Be(entity1);
var entity2 = root.AddEntity("entity2");
entity2.Name.Should().Be("entity2");
root.Entities.InCreationOrder.Count.Should().Be(2);
root.Entities.Exists(entity2.Id).Should().Be(true);
root.Entities[entity2.Id].Should().Be(entity2);
entity1.Rename("newName");
entity1.Name.Should().Be("newName");
entity2.Name.Should().Be("entity2");
entity2.Rename("newName2");
entity2.Name.Should().Be("newName2");
entity1.Name.Should().Be("newName");
root.Entities.InCreationOrder.Count.Should().Be(2);
entity2.Remove();
root.Entities.Exists(entity2.Id).Should().Be(false);
root.Entities.InCreationOrder.Count.Should().Be(1);
root.Invoking(_ => root.Entities.Get(entity2.Id)).ShouldThrow<Exception>();
root.Invoking(_ => { var __ = root.Entities[entity2.Id]; }).ShouldThrow<Exception>();
entity1.Remove();
root.Entities.Exists(entity1.Id).Should().Be(false);
root.Entities.InCreationOrder.Count.Should().Be(0);
root.Invoking(_ => root.Entities.Get(entity1.Id)).ShouldThrow<Exception>();
root.Invoking(_ => { var __ = root.Entities[entity1.Id]; }).ShouldThrow<Exception>();
}
示例2: EntityNestedInComponentWorks
public void EntityNestedInComponentWorks()
{
var root = new Root("root").Component;
var entity1 = root.AddEntity("entity1");
entity1.Name.Should().Be("entity1");
root.Entities.InCreationOrder.Count.Should().Be(1);
root.Entities.Exists(entity1.Id).Should().Be(true);
root.Entities.Get(entity1.Id).Should().Be(entity1);
root.Entities[entity1.Id].Should().Be(entity1);
var entity2 = root.AddEntity("entity2");
entity2.Name.Should().Be("entity2");
root.Entities.InCreationOrder.Count.Should().Be(2);
root.Entities.Exists(entity2.Id).Should().Be(true);
root.Entities[entity2.Id].Should().Be(entity2);
entity1.Rename("newName");
entity1.Name.Should().Be("newName");
entity2.Name.Should().Be("entity2");
entity2.Rename("newName2");
entity2.Name.Should().Be("newName2");
entity1.Name.Should().Be("newName");
root.Entities.InCreationOrder.Count.Should().Be(2);
entity2.Remove();
root.Entities.Exists(entity2.Id).Should().Be(false);
root.Entities.InCreationOrder.Count.Should().Be(1);
root.Invoking(_ => root.Entities.Get(entity2.Id)).ShouldThrow<Exception>();
root.Invoking(_ => { var __ = root.Entities[entity2.Id]; }).ShouldThrow<Exception>();
entity1.Remove();
root.Entities.Exists(entity1.Id).Should().Be(false);
root.Entities.InCreationOrder.Count.Should().Be(0);
root.Invoking(_ => root.Entities.Get(entity1.Id)).ShouldThrow<Exception>();
root.Invoking(_ => { var __ = root.Entities[entity1.Id]; }).ShouldThrow<Exception>();
}