Esempio n. 1
0
        public async Task GetAccountAsync_Should_Return_Account()
        {
            var accountId          = Guid.NewGuid();
            var getAccountResponse = new GetAccountResponse
            {
                Id    = accountId,
                Email = "*****@*****.**"
            };
            var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(getAccountResponse))
            };

            _httpClientServiceMock.Setup(x => x.GetAsync(It.IsAny <string>())).ReturnsAsync(httpResponseMessage);

            var result = await _service.GetAccountAsync(accountId);

            result.Should().BeEquivalentTo(getAccountResponse);
        }
Esempio n. 2
0
        public async Task <VerificationResult> VerifyAccountExistsAsync(Guid accountId, string email)
        {
            var account = await _rivaIdentityApiClientService.GetAccountAsync(accountId);

            if (account is null)
            {
                var errors = new Collection <IError>
                {
                    new Error(AccountErrorCodeEnumeration.NotFound, AccountErrorMessage.NotFound)
                };
                return(VerificationResult.Fail(errors));
            }

            if (!account.Email.Equals(email))
            {
                var errors = new Collection <IError>
                {
                    new Error(AccountErrorCodeEnumeration.EmailMismatch, AccountErrorMessage.EmailMismatch)
                };
                return(VerificationResult.Fail(errors));
            }

            return(VerificationResult.Ok());
        }