public void ResetDefaults_ResetsFlurlConfiguration() { RackspaceNet.Configure(); Assert.NotNull(FlurlHttp.Configuration.BeforeCall); RackspaceNet.ResetDefaults(); Assert.Null(FlurlHttp.Configuration.BeforeCall); }
public async Task UserAgentTest() { using (var httpTest = new HttpTest()) { RackspaceNet.Configure(); await "http://api.com".GetAsync(); var userAgent = httpTest.CallLog[0].Request.Headers.UserAgent.ToString(); Assert.Contains("rackspace.net", userAgent); Assert.Contains("openstack.net", userAgent); } }
public async Task UserAgentWithApplicationSuffixTest() { using (var httpTest = new HttpTest()) { RackspaceNet.Configure(configure: options => options.UserAgents.Add(new ProductInfoHeaderValue("(unit-tests)"))); await "http://api.com".GetAsync(); var userAgent = httpTest.CallLog[0].Request.Headers.UserAgent.ToString(); Assert.Contains("rackspace.net", userAgent); Assert.Contains("unit-tests", userAgent); } }
public static Mock <IAuthenticationProvider> CreateIdentityService() { RackspaceNet.Configure(); var stub = new Mock <IAuthenticationProvider>(); stub.Setup(provider => provider.GetToken(It.IsAny <CancellationToken>())) .Returns(Task.FromResult("mock-token")); stub.Setup(provider => provider.GetEndpoint(It.IsAny <IServiceType>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult("http://api.com")); return(stub); }
public async Task UserAgentOnlyListedOnceTest() { using (var httpTest = new HttpTest()) { RackspaceNet.Configure(); RackspaceNet.Configure(); await "http://api.com".GetAsync(); var userAgent = httpTest.CallLog[0].Request.Headers.UserAgent.ToString(); var rackspaceMatches = new Regex("rackspace").Matches(userAgent); Assert.Equal(1, rackspaceMatches.Count); var openstackMatches = new Regex("openstack").Matches(userAgent); Assert.Equal(1, openstackMatches.Count); } }
public void Dispose() { RackspaceNet.ResetDefaults(); }
public RackspaceNetTests() { RackspaceNet.ResetDefaults(); }