public async Task UserTriesToRegister_FirstAttempt_SuccessfullyRegistered(string referralCode) { _emailRestritionsServiceMock.Setup(x => x.IsEmailAllowed(It.IsAny <string>())) .Returns(true); var credentialsResponse = new CredentialsCreateResponse(); _credentialsClient .Setup(x => x.Api.CreateAsync(It.IsAny <CredentialsCreateRequest>())) .Returns(Task.FromResult(credentialsResponse)); _customerProfileClient.Setup(x => x.CustomerProfiles.GetByEmailAsync(It.IsAny <GetByEmailRequestModel>())) .ReturnsAsync(new CustomerProfileResponse()); _customerProfileClient .Setup(x => x.CustomerProfiles.CreateIfNotExistAsync(It.IsAny <CustomerProfileRequestModel>())) .ReturnsAsync(CustomerProfileErrorCodes.None); _pbfClient .Setup(x => x.WalletsApi.CreateAsync(It.IsAny <CustomerWalletCreationRequestModel>())) .ReturnsAsync(new CustomerWalletCreationResponseModel { Error = CustomerWalletCreationError.None }); var registrationService = CreateSutInstance(); var result = await registrationService.RegisterAsync( new RegistrationRequestDto { Email = "email", Password = "******", ReferralCode = referralCode }); Assert.NotNull(result); Assert.False(string.IsNullOrEmpty(result.CustomerId)); }
public async Task UserTriesToRegister_InvalidCountryOfNationalityId_ErrorReturned() { _emailRestritionsServiceMock.Setup(x => x.IsEmailAllowed(It.IsAny <string>())) .Returns(true); var credentialsResponse = new CredentialsCreateResponse(); _credentialsClient .Setup(x => x.Api.CreateAsync(It.IsAny <CredentialsCreateRequest>())) .Returns(Task.FromResult(credentialsResponse)); _customerProfileClient.Setup(x => x.CustomerProfiles.GetByEmailAsync(It.IsAny <GetByEmailRequestModel>())) .ReturnsAsync(new CustomerProfileResponse()); _customerProfileClient .Setup(x => x.CustomerProfiles.CreateIfNotExistAsync(It.IsAny <CustomerProfileRequestModel>())) .ReturnsAsync(CustomerProfileErrorCodes.InvalidCountryOfNationalityId); _pbfClient .Setup(x => x.WalletsApi.CreateAsync(It.IsAny <CustomerWalletCreationRequestModel>())) .ReturnsAsync(new CustomerWalletCreationResponseModel { Error = CustomerWalletCreationError.None }); var registrationService = CreateSutInstance(); var result = await registrationService.RegisterAsync( new RegistrationRequestDto { Email = "email", Password = "******" }); Assert.Equal(ServicesError.InvalidCountryOfNationalityId, result.Error); }