public async Task WhenApiSuccess_ReturnDysacResults()
        {
            var response = new DysacServiceResponse();

            response.ResponseMessage = "message";
            response.ResponseMessage = "message";
            var returnObject = Mapping.Mapper.Map <DysacJobCategory[]>(DysacTestData.SuccessfulApiCall().JobCategories);

            _client = Substitute.For <IRestClient>();
            _client.GetAsync <DysacResults>(Arg.Any <string>(), Arg.Any <HttpRequestMessage>()).Returns(DysacTestData.SuccessfulApiCall());
            _service = new DysacService(_logger, _client, _settings, _oldDysacSettings, _sessionClient);
            var result = await _service.GetDysacJobCategories("SessionId");

            result[0].JobFamilyCode.Should().Be("CAM");
            result[0].JobFamilyName.Should().Be("Creative and media");
            result[0].JobFamilyUrl.Should().Be("creative-and-media");
        }
Exemplo n.º 2
0
        private DysacServiceResponse  CreateDysacServiceResponse(AssessmentShortResponse response, Origin creationOrigin, HttpStatusCode statusCode)
        {
            var dysacServiceResponse = new DysacServiceResponse();

            if (response != null && !string.IsNullOrEmpty(response.SessionId))
            {
                dysacServiceResponse.ResponseCode = DysacReturnCode.Ok;
                var userSession = new DfcUserSession()
                {
                    CreatedDate  = DateTime.Now,
                    PartitionKey = response.PartitionKey,
                    Salt         = response.Salt,
                    SessionId    = response.SessionId,
                    Origin       = creationOrigin
                };
                _sessionClient.CreateCookie(userSession, false);
            }
            else
            {
                throw new DysacException("No session. Error Code " + statusCode);
            }

            return(dysacServiceResponse);
        }