public void GivenConstructorIsCalled_WhenErrorMessageIsNotSent_ThenFieldsAreMappedAsExpected()
        {
            var result = new NewSessionResponse();

            Assert.NotNull(result);
            Assert.False(result.Success);
            Assert.Null(result.ErrorMessage);
        }
        public void GivenConstructorIsCalled_WhenErrorMessageIsSent_ThenFieldsAreCorrectlyMapped()
        {
            var expectedErrorMessage = "Something bad happened";

            var result = new NewSessionResponse(expectedErrorMessage);

            Assert.NotNull(result);
            Assert.False(result.Success);
            Assert.Equal(expectedErrorMessage, result.ErrorMessage);
        }
Пример #3
0
 public QuestionData(NewSessionResponse response)
 {
     Question = new KeyValuePair <string, string>(
         response.parameters.step_information.questionid,
         response.parameters.step_information.question);
     Answers = response.parameters.step_information.answers
               .Select(ans => ans.answer)
               .ToList();
     Progression = response.parameters.step_information.progression;
 }
        public void GivenConstructorIsCalled_WhenValidParametersArePassed_ThenPropertiesAreCorrectlyMapped()
        {
            var expectedSessionId = "1234";
            var expectedUserId    = "5678";
            var expectedUserToken = "91011";

            var result = new NewSessionResponse(expectedSessionId, expectedUserId, expectedUserToken);

            Assert.NotNull(result);
            Assert.True(result.Success);
            Assert.Equal(expectedSessionId, result.SessionId);
            Assert.Equal(expectedUserId, result.UserId);
            Assert.Equal(expectedUserToken, result.UserToken);
        }
        public async Task NewSessionCallsCreateCookie()
        {
            var assessmentType        = "at1";
            var newAssessmentResponse = new NewSessionResponse()
            {
                SessionId = "p1-s1"
            };

            A.CallTo(() => assessmentApiService.NewSession(assessmentType)).Returns(newAssessmentResponse);

            await assessmentService.NewSession(assessmentType);

            A.CallTo(() => sessionService.CreateCookie("p1-s1")).MustHaveHappenedOnceExactly();
        }
        public async Task NewSessionReturnTrueWhenNewSessionIsCreated()
        {
            var assessmentType        = "at1";
            var newAssessmentResponse = new NewSessionResponse()
            {
                SessionId = "s1"
            };

            A.CallTo(() => assessmentApiService.NewSession(assessmentType)).Returns(newAssessmentResponse);

            var response = await assessmentService.NewSession(assessmentType);

            Assert.True(response);
        }
        public async Task StartFilteredForJobCategory_ShouldCall_CorrectUrl()
        {
            var guid     = Guid.NewGuid();
            var url      = $"{ApiRoot}/assessment/filtered/Abc123/animal-care";
            var response = new NewSessionResponse
            {
                SessionId = "Abc123"
            };

            _httpService.PostData(url, "", guid).Returns(Task.FromResult(JsonConvert.SerializeObject(response)));

            var result = await _api.StartFilteredForJobCategory(guid, "Abc123", "animal-care");

            Assert.Equal(response.SessionId, result.SessionId);
        }
        public async Task NewSession_ShouldCall_CorrectUrl()
        {
            var guid     = Guid.NewGuid();
            var url      = $"{ApiRoot}/assessment?assessmentType=short";
            var response = new NewSessionResponse
            {
                SessionId = "Abc123"
            };

            _httpService.PostData(url, "", guid).Returns(Task.FromResult(JsonConvert.SerializeObject(response)));

            var result = await _api.NewSession(guid, "short");

            Assert.Equal(response.SessionId, result.SessionId);
        }
Пример #9
0
        public void NewSessionResponse_SerializesCorrectly()
        {
            var response = new NewSessionResponse()
            {
                Capabilities = new Dictionary <string, object>()
                {
                    { "acceptInsecureCerts", false },
                    { "browserName", "firefox" },
                },
                SessionId = "1234567890",
            };

            var json = JsonConvert.SerializeObject(response, new JsonSerializerSettings()
            {
                ContractResolver = new DefaultContractResolver()
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                }
            });

            Assert.Equal("{\"sessionId\":\"1234567890\",\"capabilities\":{\"acceptInsecureCerts\":false,\"browserName\":\"firefox\"}}", json);
        }