public async Task CheckSameNameExpression_Test()
        {
            var uowManager = LocalIocManager.Resolve <IUnitOfWorkManager>();

            using (var uow = uowManager.Begin())
            {
                var repository = LocalIocManager.Resolve <IRepository <Region2, string> >();
                var config     = new GeneralTreeConfigurationWithReferenceType <Region2, string>
                {
                    CheckSameNameExpression = (regionThis, regionCheck) =>
                                              regionThis.SomeForeignKey == regionCheck.SomeForeignKey
                };

                var codeGenerate = new GeneralTreeCodeGenerate(new GeneralTreeCodeGenerateConfiguration());

                var manager =
                    new GeneralTreeManagerWithReferenceType <Region2, string>(codeGenerate, repository, config);

                //Act
                await manager.CreateAsync(new Region2
                {
                    Name           = "beijing",
                    SomeForeignKey = 1
                });

                uowManager.Current.SaveChanges();

                //Act
                await manager.CreateAsync(new Region2
                {
                    Name           = "beijing",
                    SomeForeignKey = 2
                });

                uowManager.Current.SaveChanges();

                //Assert
                var beijing1 = repository.FirstOrDefault(x => x.Name == "beijing" && x.SomeForeignKey == 1);
                beijing1.ShouldNotBeNull();

                var beijing2 = repository.FirstOrDefault(x => x.Name == "beijing" && x.SomeForeignKey == 2);
                beijing2.ShouldNotBeNull();

                uow.Complete();
            }
        }
        public async Task FullName_Hyphen_Test()
        {
            var uowManager = LocalIocManager.Resolve <IUnitOfWorkManager>();

            using (var uow = uowManager.Begin())
            {
                var repository = LocalIocManager.Resolve <IRepository <Region2, string> >();
                var config     = new GeneralTreeConfigurationWithReferenceType <Region2, string>
                {
                    Hyphen = "->"
                };

                var codeGenerate = new GeneralTreeCodeGenerate(new GeneralTreeCodeGenerateConfiguration());

                var manager =
                    new GeneralTreeManagerWithReferenceType <Region2, string>(codeGenerate, repository, config);

                //Act
                var beijing = new Region2
                {
                    Name = "beijing"
                };
                await manager.CreateAsync(beijing);

                uowManager.Current.SaveChanges();

                var xicheng = new Region2
                {
                    Name     = "xicheng",
                    ParentId = beijing.Id
                };
                await manager.CreateAsync(xicheng);

                uowManager.Current.SaveChanges();

                //Assert
                var xc = GetRegion("xicheng");
                xc.ShouldNotBeNull();
                xc.Name.ShouldBe("xicheng");
                xc.FullName.ShouldBe("beijing->xicheng");

                uow.Complete();
            }
        }
        public async Task ExceptionMessageFactory_Test()
        {
            var uowManager = LocalIocManager.Resolve <IUnitOfWorkManager>();

            using (var uow = uowManager.Begin())
            {
                var repository = LocalIocManager.Resolve <IRepository <Region2, string> >();
                var config     = new GeneralTreeConfigurationWithReferenceType <Region2, string>
                {
                    ExceptionMessageFactory =
                        tree => $"{tree.Name}已经存在"
                };

                var codeGenerate = new GeneralTreeCodeGenerate(new GeneralTreeCodeGenerateConfiguration());

                var manager =
                    new GeneralTreeManagerWithReferenceType <Region2, string>(codeGenerate, repository, config);

                //Act
                await manager.CreateAsync(new Region2
                {
                    Name = "beijing"
                });

                uowManager.Current.SaveChanges();

                //Assert
                var exception = await Record.ExceptionAsync(async() => await manager.CreateAsync(
                                                                new Region2
                {
                    Name = "beijing"
                }
                                                                ));

                exception.ShouldNotBeNull();
                exception.ShouldBeOfType <UserFriendlyException>();
                exception.Message.ShouldBe("beijing已经存在");

                uow.Complete();
            }
        }