コード例 #1
0
        public UserServiceTests()
        {
            email    = "email";
            password = "******";

            createNewPasswordResponseDto = new CreateNewPasswordResponseDto();

            userSignUpRequestDto = new UserSignUpRequestDto
            {
                Email       = email,
                Password    = password,
                FirstName   = "firstName",
                LastName    = "lastName",
                Phone       = "+380679953365",
                DateOfBirth = DateTime.Parse("12/02/1997 12:30:01")
            };

            userSignUpResponseDto = new UserSignUpResponseDto();

            httpServiceMock = new Mock <IHttpService>();
            httpServiceMock
            .SetupSequence(hs => hs.PostAsync <CreateNewPasswordRequestDto, CreateNewPasswordResponseDto>(
                               It.IsAny <Uri>(), It.IsAny <CreateNewPasswordRequestDto>(), It.IsAny <string>()))
            .ReturnsAsync(createNewPasswordResponseDto)
            .ThrowsAsync(new System.Net.WebException());

            httpServiceMock
            .SetupSequence(hs => hs.PostAsync <UserSignUpRequestDto, UserSignUpResponseDto>(
                               It.IsAny <Uri>(), It.IsAny <UserSignUpRequestDto>(), It.IsAny <string>()))
            .ReturnsAsync(userSignUpResponseDto)
            .ThrowsAsync(new System.Net.WebException());

            userService = new UserService(httpServiceMock.Object);
        }
コード例 #2
0
        public async Task <bool> CreateNewUserAsync(UserSignUpRequestDto user)
        {
            try
            {
                var response = await httpService
                               .PostAsync <UserSignUpRequestDto, UserSignUpResponseDto>(AuthorizeEndpoint.Registration, user);

                return(response.Succeeded);
            }
            catch (System.Net.WebException ex)
            {
                throw new Exceptions.WebException("Server exception", ex);
            }
            catch (SocketException ex)
            {
                throw new Exceptions.WebException("Server exception", ex);
            }
        }