示例#1
0
        public void InvokePowerBIRestMethod_ModifyHeaders()
        {
            // Arrange
            var initFactory       = new TestPowerBICmdletNoClientInitFactory(true);
            var testAuthenticator = initFactory.Authenticator;
            var accessToken       = testAuthenticator.Authenticate(profile: null, logger: null, settings: null, queryParameters: null).Result;
            var testHeaderName    = "TestExample";
            var testHeaderValue   = "Example";

            using (var client = new HttpClient())
            {
                var mock = new MockInvokePowerBIRestMethodCmdlet(initFactory)
                {
                    Headers = new System.Collections.Hashtable()
                    {
                        { testHeaderName, testHeaderValue }
                    }
                };

                // Act
                mock.InvokePopulateClient(accessToken, client);

                // Assert
                Assert.AreEqual(0, client.DefaultRequestHeaders.Accept.Count);
                Assert.IsTrue(client.DefaultRequestHeaders.TryGetValues(testHeaderName, out IEnumerable <string> headerValues));
                Assert.IsNotNull(headerValues);
                Assert.AreEqual(1, headerValues.Count());
                Assert.AreEqual(testHeaderValue, headerValues.First());
            }
        }
示例#2
0
        public void InvokePowerBIRestMethod_DefaultTimeout()
        {
            // Arrange
            var initFactory       = new TestPowerBICmdletNoClientInitFactory(true);
            var testAuthenticator = initFactory.Authenticator;
            var accessToken       = testAuthenticator.Authenticate(profile: null, logger: null, settings: null, queryParameters: null).Result;

            using (var client = new HttpClient())
            {
                var mock = new MockInvokePowerBIRestMethodCmdlet(initFactory);

                // Act
                mock.InvokePopulateClient(accessToken, client);

                // Assert
                Assert.AreEqual(client.Timeout, TimeSpan.FromSeconds(100)); // default http client timeout
            }
        }