Exemplo n.º 1
0
        public void Rename(ITableCategory category, TaskContext context)
        {
            category.Dispatcher.Invoke(() =>
            {
                var categoryName = RandomUtility.NextIdentifier();
                if (Verify() == false)
                {
                    return;
                }
                category.Rename(context.Authentication, categoryName);
            });

            bool Verify()
            {
                if (context.AllowException == true)
                {
                    return(true);
                }
                if (category.Parent == null)
                {
                    return(false);
                }
                return(true);
            }
        }
Exemplo n.º 2
0
        public static void RenameTest(this ITableCategory category, Authentication authentication)
        {
            Assert.AreNotEqual(null, category.Parent);
            var parent  = category.Parent;
            var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), parent.Categories.Select(item => item.Name));

            category.Rename(authentication, newName);
        }
Exemplo n.º 3
0
        public void CategoryLockRenameTest()
        {
            cremaHost.Dispatcher.Invoke(() =>
            {
                var newName = RandomUtility.NextIdentifier();
                category.Lock(authentication, string.Empty);
                category.Rename(authentication, newName);

                Assert.AreEqual(category.Path, category.LockInfo.Path);
            });
        }
 public static void RenameFailTest <T>(ICremaHost cremaHost, ITableCategory category, Authentication authentication) where T : Exception
 {
     cremaHost.Dispatcher.Invoke(() =>
     {
         try
         {
             category.Rename(authentication, RandomUtility.NextIdentifier());
             Assert.Fail("Rename");
         }
         catch (T)
         {
         }
     });
 }
Exemplo n.º 5
0
 public static void RenameFailTest <T>(ITableCategory category, Authentication authentication) where T : Exception
 {
     Assert.AreNotEqual(null, category.Parent);
     category.Dispatcher.Invoke(() =>
     {
         try
         {
             var parent  = category.Parent;
             var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), parent.Categories.Select(item => item.Name));
             category.Rename(authentication, newName);
             Assert.Fail("RenameFailTest");
         }
         catch (T)
         {
         }
     });
 }
 public void Rename()
 {
     category.Rename(authentication, RandomUtility.NextIdentifier());
 }
Exemplo n.º 7
0
        private void MoveTableCategory(Authentication authentication, ITableCategory sourceCategory, string newPath)
        {
            var destPath   = new DataBasePath(newPath);
            var destObject = this.GetObject(authentication, destPath.Path);

            this.CremaHost.Dispatcher.Invoke(MoveTableCategory);

            void MoveTableCategory()
            {
                var dataBase = sourceCategory.GetService(typeof(IDataBase)) as IDataBase;
                var tables   = sourceCategory.GetService(typeof(ITableCollection)) as ITableCollection;

                if (destPath.DataBaseName != dataBase.Name)
                {
                    throw new InvalidOperationException($"cannot move to : {destPath}");
                }
                if (destPath.Context != CremaSchema.TableDirectory)
                {
                    throw new InvalidOperationException($"cannot move to : {destPath}");
                }
                if (destObject is ITable)
                {
                    throw new InvalidOperationException($"cannot move to : {destPath}");
                }

                using (DataBaseUsing.Set(dataBase, authentication))
                {
                    if (destObject is ITableCategory destCategory)
                    {
                        if (sourceCategory.Parent != destCategory)
                        {
                            sourceCategory.Move(authentication, destCategory.Path);
                        }
                    }
                    else
                    {
                        if (NameValidator.VerifyCategoryPath(destPath.ItemPath) == true)
                        {
                            throw new InvalidOperationException($"cannot move to : {destPath}");
                        }
                        var itemName   = new ItemName(destPath.ItemPath);
                        var categories = sourceCategory.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection;
                        if (categories.Contains(itemName.CategoryPath) == false)
                        {
                            throw new InvalidOperationException($"cannot move to : {destPath}");
                        }
                        if (sourceCategory.Name != itemName.Name && tables.Contains(itemName.Name) == true)
                        {
                            throw new InvalidOperationException($"cannot move to : {destPath}");
                        }
                        if (sourceCategory.Parent.Path != itemName.CategoryPath)
                        {
                            sourceCategory.Move(authentication, itemName.CategoryPath);
                        }
                        if (sourceCategory.Name != itemName.Name)
                        {
                            sourceCategory.Rename(authentication, itemName.Name);
                        }
                    }
                }
            }
        }