예제 #1
0
        public async Task AddUser_AfterAdded_Success()
        {
            AddUserService addUserService = new AddUserService(
                UserManagerMock.Create().WithCreateSuccess().Object,
                SignInManagerMock.Create().Object,
                IEmailConfirmationServiceMock.Create().SendVerificationMailSuccess().Object,
                IGroupUserServiceMock.Create().Object,
                IAddUserFilterMock.Create().BeforeAdd_Success().AfterAdded_Success().Object,
                IBaseDAOMock<AppUserEntity>.Create().Object,
                IBaseDAOMock<InviteEntity>.Create().Object,
                IBaseDAOMock<RoleEntity>.Create().Object,
                IOptionsMock<IdentityUIEndpoints>.Create().DefaultValue().Object,
                IValidatorMock<NewUserRequest>.Create().Object,
                IValidatorMock<RegisterRequest>.Create().Object,
                IValidatorMock<AcceptInviteRequest>.Create().Object,
                IValidatorMock<ExternalLoginRegisterRequest>.Create().Object,
                IValidatorMock<GroupBaseUserRegisterRequest>.Create().Object,
                IValidatorMock<BaseRegisterRequest>.Create().Validate_Valid().Object,
                IValidatorMock<IUserAttributeRequest>.Create().Validate_Valid().Object,
                NullLogger<AddUserService>.Instance);

            BaseRegisterRequest baseRegisterRequest = new Fixture()
                .Build<BaseRegisterRequest>()
                .Create();

            Result<AppUserEntity> result = await addUserService.AddUser(baseRegisterRequest);

            result.Success.Should().BeTrue();
        }
예제 #2
0
        public async Task AddUserToGroupWithoutValidation_AfterAdded_Success()
        {
            GroupUserService groupUserService = new GroupUserService(
                IBaseDAOMock <GroupUserEntity> .Create().Add_Success().Object,
                IBaseDAOMock <RoleEntity> .Create().Object,
                IBaseDAOMock <AppUserEntity> .Create().Object,
                IBaseDAOMock <GroupEntity> .Create().Object,
                IGroupUserStoreMock.Create().Object,
                IAddGroupUserFilterMock.Create().BeforeAdd_Success().AfterAdded_Success().Object,
                IValidatorMock <AddExistingUserRequest> .Create().Object,
                NullLogger <GroupUserService> .Instance);

            Result <GroupUserEntity> result = await groupUserService.AddUserToGroupWithoutValidation("user_id", "group_id", "role_id");

            result.Success.Should().BeTrue();
        }
예제 #3
0
        public async Task AddUserToGroupWithoutValidation_AfterAdded_Failure()
        {
            GroupUserService groupUserService = new GroupUserService(
                IBaseDAOMock <GroupUserEntity> .Create().Add_Success().Object,
                IBaseDAOMock <RoleEntity> .Create().Object,
                IBaseDAOMock <AppUserEntity> .Create().Object,
                IBaseDAOMock <GroupEntity> .Create().Object,
                IGroupUserStoreMock.Create().Object,
                IAddGroupUserFilterMock.Create().BeforeAdd_Success().AfterAdded_Failure().Object,
                IValidatorMock <AddExistingUserRequest> .Create().Object,
                NullLogger <GroupUserService> .Instance);

            Result <GroupUserEntity> result = await groupUserService.AddUserToGroupWithoutValidation("user_id", "group_id", "role_id");

            result.Success.Should().BeFalse();
            result.ResultMessages.Should().Contain(x => x.Code == TesttConstants.RESULT_ERROR_CODE);
        }
예제 #4
0
        public async Task Add_AfterAdded_Success()
        {
            InviteService inviteService = new InviteService(
                IBaseDAOMock <AppUserEntity> .Create().Exists_Failure().Object,
                IBaseDAOMock <RoleEntity> .Create().Object,
                IBaseDAOMock <InviteEntity> .Create().Add_Success().Exists_Failure().Object,
                IGroupStoreMock.Create().Object,
                IGroupUserStoreMock.Create().Object,
                IEmailServiceMock.Create().SendInvite_Success().Object,
                IAddInviteFilterMock.Create().BeforeAdd_Success().AfterAdded_Success().Object,
                IValidatorMock <InviteToGroupRequest> .Create().Object,
                IValidatorMock <InviteRequest> .Create().Object,
                NullLogger <InviteService> .Instance,
                IOptionsMock <IdentityUIOptions> .Create().DefaultValue().Object,
                IOptionsMock <IdentityUIEndpoints> .Create().DefaultValue().Object);

            Result result = await inviteService.AddInvite("email");

            result.Success.Should().BeTrue();
        }