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


C# Root.Invoking方法代码示例

本文整理汇总了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>();
        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:39,代码来源:NestedEntitiesTests.cs

示例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>();
        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:39,代码来源:NestedEntitiesTests.cs


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