コード例 #1
0
        public async Task UpgradePlan_WhenProposedPlanSameAsCurrentPlan_ThrowsException()
        {
            var request = new UpgradePlanRequest()
            {
                Plan = Account.CurrentPlan.GetPlanType()
            };

            await Assert.ThrowsAsync <InvalidUpgradePlanException>(
                async() => await Orchestrator.UpgradePlan(Account.Id, request));
        }
コード例 #2
0
        public async Task UpgradePlan_InvalidPlan_ThrowsException()
        {
            var request = new UpgradePlanRequest()
            {
                Plan = (Plan)100
            };

            await Assert.ThrowsAsync <InvalidPlanException>(
                async() => await Orchestrator.UpgradePlan(Account.Id, request));
        }
コード例 #3
0
        public async Task UpgradePlan_WhenProposedPlanLesserThanCurrentPlan_ThrowsException()
        {
            var request = new UpgradePlanRequest()
            {
                Plan = (Plan)1
            };

            await Assert.ThrowsAsync <InvalidUpgradePlanException>(
                async() => await Orchestrator.UpgradePlan(Account.Id, request));
        }
コード例 #4
0
        public async Task UpgradePlan(Guid accountId, UpgradePlanRequest request)
        {
            var account = await Repository.GetAccountBy(accountId);

            if (DoesntExist(account))
            {
                throw new AccountNotFoundException();
            }

            if (!IsPlanValid(request.Plan))
            {
                throw new InvalidPlanException();
            }

            if (IsProposedPlanLessThanCurrentPlan(request.Plan, account))
            {
                throw new InvalidUpgradePlanException();
            }

            await Repository.UpgradePlan(accountId, request.Plan);
        }
コード例 #5
0
 private async Task UpgradePlan(Guid id, UpgradePlanRequest request)
 {
     await _client.PutAsync($"{ControllerUrl}/{id}", GetHttpContentFromObj(request));
 }
コード例 #6
0
 public UpgradePlanRequest GetUpgradePlanRequest(byte[] result)
 {
     return(UpgradePlanRequest.ParseFrom(result));
 }
コード例 #7
0
        public async Task <IActionResult> UpgradePlan(Guid accountId, [FromBody] UpgradePlanRequest request)
        {
            await Orchestrator.UpgradePlan(accountId, request);

            return(Ok());
        }