private void IncluirUsuario(UserAppService appService, out UserViewModel user, out UserViewModel userReturn)
        {
            var changed = fakeData.FirstOrDefault();

            Assert.NotNull(changed);

            user = new UserViewModel
            {
                Name     = $"{changed.Name} _teste",
                Email    = $"{changed.Email} .br",
                Password = "******",
                Role     = Constants.PERFIL_USUARIO,
                Active   = false
            };
            userReturn = appService.Add(user);
        }
コード例 #2
0
        public void ApplService_User_deveria_adicionar()
        {
            //Arrange
            long expectedId = 1;
            var  user       = ObjectMother.userDefault;

            user.Id = expectedId;
            var userAddCommand = ObjectMother.userAddCommand;

            _repository.Setup(x => x.Add(It.IsAny <User>())).Returns(user);

            //Action
            var result = _appService.Add(userAddCommand);

            //Assert
            result.Id.Should().Be((int)user.Id);
            _repository.Verify(x => x.Add(It.IsAny <User>()), Times.Once);
            _repository.VerifyNoOtherCalls();
        }
コード例 #3
0
ファイル: RegUtils.cs プロジェクト: china99ljs/wojilu
        private static void addUserAppAndMenus(User user, MvcContext ctx)
        {
            if (strUtil.IsNullOrEmpty(config.Instance.Site.UserInitApp))
            {
                return;
            }

            IMemberAppService appService  = new UserAppService();
            IMenuService      menuService = new UserMenuService();

            List <String> menus = new List <string>();

            String[] arr = config.Instance.Site.UserInitApp.Split(',');
            foreach (String app in arr)
            {
                if (strUtil.IsNullOrEmpty(app))
                {
                    continue;
                }
                menus.Add(app.Trim());
            }

            if (menus.Contains("home"))
            {
                new UserHomeInstaller().Install(ctx, user, wojilu.lang.get("homepage"), wojilu.Common.AppBase.AccessStatus.Public);
            }

            if (menus.Contains("blog"))
            {
                IMemberApp blogApp = appService.Add(user, "博客", 2);
                // 添加菜单:此处需要明确传入MemberType,否则将会使用ctx.Owner,也就是Site的值,导致bug
                String blogUrl = UrlConverter.clearUrl(alink.ToUserAppFull(blogApp), ctx, typeof(User).FullName, user.Url);
                menuService.AddMenuByApp(blogApp, blogApp.Name, "", blogUrl);
            }

            if (menus.Contains("photo"))
            {
                IMemberApp photoApp = appService.Add(user, "相册", 3);
                String     photoUrl = UrlConverter.clearUrl(alink.ToUserAppFull(photoApp), ctx, typeof(User).FullName, user.Url);
                menuService.AddMenuByApp(photoApp, photoApp.Name, "", photoUrl);
            }

            if (menus.Contains("microblog"))
            {
                IMenu menu = getMenu(user, "微博", alink.ToUserMicroblog(user), ctx);
                menuService.Insert(menu, user, user);
            }

            //if (menus.Contains( "share" )) {
            //    IMenu menu = getMenu( user, "转帖", lnkToUser( new Users.ShareController().Index ), ctx );
            //    menuService.Insert( menu, user, user );
            //}

            if (menus.Contains("friend"))
            {
                IMenu menu = getMenu(user, "好友", lnkToUser(user, new Users.FriendController().FriendList), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("visitor"))
            {
                IMenu menu = getMenu(user, "访客", lnkToUser(user, new Users.VisitorController().Index), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("forumpost"))
            {
                IMenu menu = getMenu(user, "论坛帖子", lnkToUser(user, new Users.ForumController().Topic), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("about"))
            {
                IMenu menu = getMenu(user, "关于我", lnkToUser(user, new Users.ProfileController().Main), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("feedback"))
            {
                IMenu menu = getMenu(user, "留言", lnkToUser(user, new Users.FeedbackController().List), ctx);
                menuService.Insert(menu, user, user);
            }
        }