Пример #1
0
 /// <summary>
 /// 更新实体以及所有下级节点路径
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <typeparam name="TKey">标识类型</typeparam>
 /// <typeparam name="TParentId">父标识类型</typeparam>
 /// <param name="repository">仓储</param>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public static async Task UpdatePathAsync <TEntity, TKey, TParentId>(
     this ITreeCompactRepository <TEntity, TKey, TParentId> repository, TEntity entity)
     where TEntity : class, ITreeEntity <TEntity, TKey, TParentId>
 {
     var manager = new UpdatePathManager <TEntity, TKey, TParentId>(repository);
     await manager.UpdatePathAsync(entity);
 }
        public async Task TestUpdatePathAsync_1()
        {
            //设置
            string path = $"{_id},";

            _mockRepository.FindAsync(_id).ReturnsNull();

            //执行
            Role role = new Role(_id, path, 0)
            {
                ParentId = _id2
            };
            await _manager.UpdatePathAsync(role);

            //验证
            await _mockRepository.DidNotReceive().GetAllChildrenAsync(role);

            Assert.Equal(path, role.Path);
        }