Exemplo n.º 1
0
        public void AssignDepositLimitsTest_ChecksThatDepositLimitsAreAssignedProperlyWhenLevel1IsNotVerifiedAndBalanceIsAlreadyPresent_VerifiesThroughReturnedValues()
        {
            IDepositApplicationService    depositApplicationService = (IDepositApplicationService)ContextRegistry.GetContext()["DepositApplicationService"];
            IDepositLimitRepository       depositLimitRepository    = (IDepositLimitRepository)ContextRegistry.GetContext()["DepositLimitRepository"];
            StubTierLevelRetrievalService tierLevelRetrieval        = (StubTierLevelRetrievalService)ContextRegistry.GetContext()["TierLevelRetrievalService"];

            tierLevelRetrieval.SetTierLevel("Tier 0");
            DepositLimit depositLimit = depositLimitRepository.GetLimitByTierLevelAndCurrency("Tier 0", LimitsCurrency.Default.ToString());

            Assert.IsNotNull(depositLimit);
            Assert.AreEqual(0, depositLimit.DailyLimit);
            Assert.AreEqual(0, depositLimit.MonthlyLimit);
            AccountId accountId = new AccountId(123);
            Currency  currency  = new Currency("BTC", true);

            DepositLimitThresholdsRepresentation depositLimitThresholds = depositApplicationService.GetThresholdLimits(accountId.Value, currency.Name);

            Assert.IsNotNull(depositLimitThresholds);
            Assert.AreEqual(depositLimit.DailyLimit, depositLimitThresholds.DailyLimit);
            Assert.AreEqual(depositLimit.MonthlyLimit, depositLimitThresholds.MonthlyLimit);
            Assert.AreEqual(0, depositLimitThresholds.DailyLimitUsed);
            Assert.AreEqual(0, depositLimitThresholds.MonthlyLimitUsed);
            Assert.AreEqual(0, depositLimitThresholds.CurrentBalance);
            Assert.AreEqual(0, depositLimitThresholds.MaximumDeposit);
        }
Exemplo n.º 2
0
        public void AssignDepositLimitsTest_ChecksThatDepositLimitsAreNotAssignedWhenNoDepositLimitIsFound_VerifiesThroughReturnedValues()
        {
            IDepositApplicationService    depositApplicationService = (IDepositApplicationService)ContextRegistry.GetContext()["DepositApplicationService"];
            IDepositLimitRepository       depositLimitRepository    = (IDepositLimitRepository)ContextRegistry.GetContext()["DepositLimitRepository"];
            StubTierLevelRetrievalService tierLevelRetrieval        = (StubTierLevelRetrievalService)ContextRegistry.GetContext()["TierLevelRetrievalService"];

            // Specify invalid tier level
            tierLevelRetrieval.SetTierLevel("Tier 6");
            DepositLimit depositLimit = depositLimitRepository.GetLimitByTierLevelAndCurrency("Tier 0", LimitsCurrency.Default.ToString());

            Assert.IsNotNull(depositLimit);
            Assert.AreEqual(0, depositLimit.DailyLimit);
            Assert.AreEqual(0, depositLimit.MonthlyLimit);
            AccountId accountId = new AccountId(123);
            Currency  currency  = new Currency("BTC", true);

            // Exception occurs here because there is no such level as Tier 6
            depositApplicationService.GetThresholdLimits(accountId.Value, currency.Name);
        }
 public IHttpActionResult GetDepositLimits([FromBody] GetDepositLimitsParams getDepositLimitsParams)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(string.Format("Get Deposit Limits call: Currency = {0}", getDepositLimitsParams.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 Deposit Limits Call: ApiKey = {0}", apikey));
         }
         if (!string.IsNullOrEmpty(apikey) && !string.IsNullOrEmpty(getDepositLimitsParams.Currency))
         {
             int accountId = _apiKeyInfoAccess.GetUserIdFromApiKey(apikey);
             return(Ok(_depositApplicationService.GetThresholdLimits(accountId, getDepositLimitsParams.Currency)));
         }
         return(BadRequest("Currency is not provided or API key not found with request"));
     }
     catch (Exception exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error(string.Format("Get Deposit Limits Call Error: {0}", exception));
         }
         return(InternalServerError());
     }
 }
Exemplo n.º 4
0
        public void AssignDepositLimits2Test_ChecksThatDepositLimitsAreAssignedProperlyWhenLevel1IsVerifiedAndBalanceIsAlreadyPresent_VerifiesThroughReturnedValues()
        {
            IDepositApplicationService  depositApplicationService  = (IDepositApplicationService)ContextRegistry.GetContext()["DepositApplicationService"];
            IDepositLimitRepository     depositLimitRepository     = (IDepositLimitRepository)ContextRegistry.GetContext()["DepositLimitRepository"];
            IFundsPersistenceRepository fundsPersistenceRepository = (IFundsPersistenceRepository)ContextRegistry.GetContext()["FundsPersistenceRepository"];

            DepositLimit depositLimit  = depositLimitRepository.GetLimitByTierLevelAndCurrency("Tier 1", LimitsCurrency.Default.ToString());
            AccountId    accountId     = new AccountId(123);
            Currency     currency      = new Currency("BTC", true);
            decimal      balanceAmount = 100;
            Balance      balance       = new Balance(currency, accountId, balanceAmount, balanceAmount);

            fundsPersistenceRepository.SaveOrUpdate(balance);

            DepositLimitThresholdsRepresentation depositLimitThresholds = depositApplicationService.GetThresholdLimits(accountId.Value, currency.Name);

            Assert.IsNotNull(depositLimitThresholds);
            Assert.AreEqual(depositLimit.DailyLimit, depositLimitThresholds.DailyLimit);
            Assert.AreEqual(depositLimit.MonthlyLimit, depositLimitThresholds.MonthlyLimit);
            Assert.AreEqual(0, depositLimitThresholds.DailyLimitUsed);
            Assert.AreEqual(0, depositLimitThresholds.MonthlyLimitUsed);
            Assert.AreEqual(balanceAmount, depositLimitThresholds.CurrentBalance);
            Assert.AreEqual(depositLimit.DailyLimit, depositLimitThresholds.MaximumDeposit);
        }