Ejemplo n.º 1
0
 public void ResetDefaults_ResetsFlurlConfiguration()
 {
     RackspaceNet.Configure();
     Assert.NotNull(FlurlHttp.Configuration.BeforeCall);
     RackspaceNet.ResetDefaults();
     Assert.Null(FlurlHttp.Configuration.BeforeCall);
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 public void Dispose()
 {
     RackspaceNet.ResetDefaults();
 }
Ejemplo n.º 7
0
 public RackspaceNetTests()
 {
     RackspaceNet.ResetDefaults();
 }