예제 #1
0
        public void DoAuthenticatedRequest_OnOK_It_Will_Not_Try_To_ReAuhthenticate()
        {
            clientMock.Setup(c => c.Execute <TestPocoClass>(It.IsAny <IRestRequest>())).Returns(new RestResponse <TestPocoClass>()
            {
                StatusCode = HttpStatusCode.OK
            });

            var response = jiraApiRequester.DoAuthenticatedRequest <TestPocoClass>(new Mock <IRestRequest>().Object);

            jiraApiRequestFactoryMock.Verify(m => m.CreateReAuthenticateRequest(), Times.Never);
        }
예제 #2
0
        public void DoAuthenticatedRequest_WithValidCredentials()
        {
            var valid_username = "******";
            var valid_apitoken = "validapitoken";

            var requestMock = new RestRequest();

            clientMock.Setup(c => c.Execute <TestPocoClass>(It.IsAny <IRestRequest>())).Returns(() => TestAuth(requestMock, valid_username, valid_apitoken));

            jiraApiRequester.SetAuthentication(valid_username, valid_apitoken);

            var response = jiraApiRequester.DoAuthenticatedRequest <TestPocoClass>(requestMock);

            Assert.NotNull(response);
            Assert.IsEmpty(jiraApiRequester.ErrorMessage);
        }