public void TestInitializedAccessGivesResult() { HttpClientSingleton.Initialize(true, TimeSpan.FromSeconds(600)); var h = HttpClientSingleton.GetClient(); bool result = h != null; HttpClientSingleton.Clear(); Assert.True(result); }
public void TestDoubleInitializeThrowsError() { HttpClientSingleton.Initialize(true, TimeSpan.FromSeconds(600)); try { HttpClientSingleton.Initialize(true, TimeSpan.FromSeconds(600)); } catch (InvalidOperationException) { HttpClientSingleton.Clear(); Assert.Pass(); return; } HttpClientSingleton.Clear(); Assert.Fail(); }
public CxRestContext Build() { if (_url == null) { throw new InvalidOperationException("Endpoint URL was not specified."); } if (_user == null) { throw new InvalidOperationException("Username was not specified."); } if (_pass == null) { throw new InvalidOperationException("Password was not specified."); } var timeoutSpan = new TimeSpan(0, 0, _timeout); HttpClientSingleton.Initialize(_validate, timeoutSpan); CxRestContext retVal = new CxRestContext() { SastToken = GetLoginToken(_url, _user, _pass, SAST_SCOPE), MNOToken = GetLoginToken(_url, _user, _pass, $"{MNO_SCOPE} {SAST_SCOPE}"), Url = _url, MnoUrl = String.IsNullOrEmpty(_mnoUrl) ? _url : _mnoUrl, ValidateSSL = _validate, Timeout = timeoutSpan }; retVal.Json = new CxClientFactory("application/json", retVal); retVal.Xml = new CxClientFactory("application/xml", retVal); return(retVal); }