Exemplo n.º 1
0
        public void SetCredentialOnHandler_GivenHandlerIsNull_ShouldReturnNull()
        {
            //---------------Set up test pack-------------------
            var webSource         = TestUtils.CreateWebSourceWithCredentials();
            var httpClientHandler = HttpClientCredentialManager.SetCredentialOnHandler(webSource, null);

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.IsNull(httpClientHandler);
        }
Exemplo n.º 2
0
        public void SetCredentialOnHandler_GivenSourceIsAnonymousAuth_ShouldReturnHttpHandlerWithNoCredentials()
        {
            //---------------Set up test pack-------------------
            var webSource         = TestUtils.CreateWebSourceWithCredentials();
            var clientHandler     = new HttpClientHandler();
            var httpClientHandler = HttpClientCredentialManager.SetCredentialOnHandler(webSource, clientHandler);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(clientHandler);
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.IsNotNull(httpClientHandler);
        }
Exemplo n.º 3
0
        public void SetCredentialOnHandler_GivenSourceIsUserAuth_ShouldReturnHttpHandlerWithCredentials()
        {
            //---------------Set up test pack-------------------
            var webSource         = TestUtils.CreateWebSourceWithCredentials();
            var clientHandler     = new HttpClientHandler();
            var httpClientHandler = HttpClientCredentialManager.SetCredentialOnHandler(webSource, clientHandler);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(clientHandler);
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.IsNotNull(httpClientHandler);
            var credential = (NetworkCredential)httpClientHandler.Credentials;

            Assert.AreEqual("Passwr1", credential.Password);
            Assert.AreEqual("User1", credential.UserName);
        }