Beispiel #1
0
        public async Task IssueMessageIfAddSolutionsFails()
        {
            // Arrange

            // Act
            var result = await sutFailure.AddSolutions(10);

            // Assert
            Assert.That(result.Success, Is.False);
            Assert.That(result.Message, Is.EqualTo("Solutions not Added"));
        }
Beispiel #2
0
        public async Task AddSolutions()
        {
            // Arrange

            // Act
            var result = await sut.AddSolutions(10);

            // Assert
            Assert.That(result.Success, Is.True);
            Assert.That(result.Message, Is.EqualTo("Solutions Added"));
        }
        public async Task <IActionResult> AddSolutions(
            [FromBody] AddSolutionRequest request)
        {
            if (await appsService.IsRequestValidOnThisLicense(
                    request.AppId,
                    request.License,
                    request.RequestorId))
            {
                if (request.Limit <= 1000)
                {
                    var result = await solutionService.AddSolutions(request.Limit);

                    if (result.Success)
                    {
                        result.Message = ControllerMessages.StatusCode200(result.Message);

                        return(Ok(result));
                    }
                    else
                    {
                        result.Message = ControllerMessages.StatusCode404(result.Message);

                        return(NotFound(result));
                    }
                }
                else
                {
                    return(BadRequest(
                               ControllerMessages.StatusCode400(
                                   string.Format(
                                       "The Amount Of Solutions Requested, {0}, Exceeds The Service's 1,000 Limit",
                                       request.Limit.ToString())
                                   )));
                }
            }
            else
            {
                return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage));
            }
        }