public void AssignWithdrawLimitsTest_TestsIfWithdrawLimitsGetAsignedProperlyWhenTier1IsNotVerified_VerifiesThroughReturnedValue() { IWithdrawApplicationService withdrawApplicationService = (IWithdrawApplicationService)ContextRegistry.GetContext()["WithdrawApplicationService"]; IWithdrawLimitRepository withdrawLimitRepository = (IWithdrawLimitRepository)ContextRegistry.GetContext()["WithdrawLimitRepository"]; IWithdrawFeesRepository withdrawFeesRepository = (IWithdrawFeesRepository)ContextRegistry.GetContext()["WithdrawFeesRepository"]; StubTierLevelRetrievalService tierLevelRetrievalService = (ITierLevelRetrievalService)ContextRegistry.GetContext()["TierLevelRetrievalService"] as StubTierLevelRetrievalService; Assert.IsNotNull(tierLevelRetrievalService); tierLevelRetrievalService.SetTierLevel(TierConstants.TierLevel0); AccountId accountId = new AccountId(123); Currency currency = new Currency("BTC", true); WithdrawLimit withdrawLimit = withdrawLimitRepository.GetLimitByTierLevelAndCurrency("Tier 1", LimitsCurrency.Default.ToString()); Assert.IsNotNull(withdrawLimit); WithdrawFees withdrawFees = withdrawFeesRepository.GetWithdrawFeesByCurrencyName(currency.Name); Assert.IsNotNull(withdrawFees); WithdrawLimitRepresentation withdrawLimitRepresentation = withdrawApplicationService.GetWithdrawLimitThresholds(accountId.Value, currency.Name); Assert.IsNotNull(withdrawLimitRepresentation); Assert.AreEqual(currency.Name, withdrawLimitRepresentation.Currency); Assert.AreEqual(accountId.Value, withdrawLimitRepresentation.AccountId); Assert.AreEqual(0, withdrawLimitRepresentation.DailyLimit); Assert.AreEqual(0, withdrawLimitRepresentation.MonthlyLimit); Assert.AreEqual(0, withdrawLimitRepresentation.DailyLimitUsed); Assert.AreEqual(0, withdrawLimitRepresentation.MonthlyLimitUsed); Assert.AreEqual(0, withdrawLimitRepresentation.CurrentBalance); Assert.AreEqual(withdrawFees.Fee, withdrawLimitRepresentation.Fee); Assert.AreEqual(withdrawFees.MinimumAmount, withdrawLimitRepresentation.MinimumAmount); Assert.AreEqual(0, withdrawLimitRepresentation.Withheld); Assert.AreEqual(0, withdrawLimitRepresentation.MaximumWithdraw); }
public void AssignWithdrawLimitsTest_TestsIfWithdrawLimitsGetAsignedProperlyWhenInvalidTierLevelIsSpecified_VerifiesThroughReturnedValue() { IWithdrawApplicationService withdrawApplicationService = (IWithdrawApplicationService)ContextRegistry.GetContext()["WithdrawApplicationService"]; IWithdrawFeesRepository withdrawFeesRepository = (IWithdrawFeesRepository)ContextRegistry.GetContext()["WithdrawFeesRepository"]; StubTierLevelRetrievalService tierLevelRetrievalService = (ITierLevelRetrievalService)ContextRegistry.GetContext()["TierLevelRetrievalService"] as StubTierLevelRetrievalService; Assert.IsNotNull(tierLevelRetrievalService); tierLevelRetrievalService.SetTierLevel("Tier 6"); AccountId accountId = new AccountId(123); Currency currency = new Currency("BTC", true); WithdrawFees withdrawFees = withdrawFeesRepository.GetWithdrawFeesByCurrencyName(currency.Name); Assert.IsNotNull(withdrawFees); withdrawApplicationService.GetWithdrawLimitThresholds(accountId.Value, currency.Name); }
public IHttpActionResult GetWithdrawLimits([FromBody] GetWithdrawLimitsParams getWithdrawLimitsParams) { if (log.IsDebugEnabled) { log.Debug(string.Format("Get Withdrawal Limits call: Currency = {0}", getWithdrawLimitsParams.Currency)); } try { //get api key from header var headers = Request.Headers; string apikey = ""; IEnumerable <string> headerParams; if (headers.TryGetValues("Auth", out headerParams)) { string[] auth = headerParams.ToList()[0].Split(','); apikey = auth[0]; } if (log.IsDebugEnabled) { log.Debug(string.Format("Get Withdrawal Limits Call: ApiKey = {0}", apikey)); } if (!string.IsNullOrEmpty(getWithdrawLimitsParams.Currency)) { int accountId = _apiKeyInfoAccess.GetUserIdFromApiKey(apikey); return(Ok(_withdrawApplicationService.GetWithdrawLimitThresholds(accountId, getWithdrawLimitsParams.Currency))); } return(BadRequest("Currency is not provided.")); } catch (Exception exception) { if (log.IsErrorEnabled) { log.Error(string.Format("Get Withdrawal Limits Call Error: {0}", exception)); } return(InternalServerError()); } }