public void TryGetPropertyIsCaseSensitive()
        {
            HttpPipelineMessage message = new HttpPipelineMessage(new MockRequest(), new ResponseClassifier(), CancellationToken.None);

            message.SetProperty("someName", "value");


            Assert.False(message.TryGetProperty("SomeName", out _));
        }
        public void TryGetPropertyReturnsValueIfSet()
        {
            HttpPipelineMessage message = new HttpPipelineMessage(CancellationToken.None);

            message.SetProperty("someName", "value");

            Assert.True(message.TryGetProperty("someName", out object value));
            Assert.AreEqual("value", value);
        }
        public void TryGetPropertyReturnsValueIfSet()
        {
            HttpPipelineMessage message = new HttpPipelineMessage(new MockRequest(), new ResponseClassifier(), CancellationToken.None);

            message.SetProperty("someName", "value");

            Assert.True(message.TryGetProperty("someName", out object value));
            Assert.AreEqual("value", value);
        }
Beispiel #4
0
        public void OnSendingRequest_ThirdTry_ShouldUsePrimary_ShouldSetAlternateToSecondary()
        {
            var message = new HttpPipelineMessage(
                CreateMockRequest(MockSecondaryUri),
                new StorageResponseClassifier(MockSecondaryUri));

            message.SetProperty(Constants.GeoRedundantRead.AlternateHostKey, MockPrimaryUri.Host);
            var policy = new GeoRedundantReadPolicy(MockSecondaryUri);

            policy.OnSendingRequest(message);

            Assert.AreEqual(MockPrimaryUri.Host, message.Request.Uri.Host);
            Assert.IsTrue(message.TryGetProperty(Constants.GeoRedundantRead.AlternateHostKey, out object val) &&
                          (string)val == MockSecondaryUri.Host);
        }
Beispiel #5
0
        public void OnSendingRequest_404onSecondary_ShouldSetNotFoundFlag_ShouldUsePrimary()
        {
            var message = new HttpPipelineMessage(
                CreateMockRequest(MockSecondaryUri),
                new StorageResponseClassifier(MockSecondaryUri))

            {
                Response = new MockResponse(Constants.HttpStatusCode.NotFound)
            };

            message.SetProperty(Constants.GeoRedundantRead.AlternateHostKey, MockSecondaryUri.Host);
            var policy = new GeoRedundantReadPolicy(MockSecondaryUri);

            policy.OnSendingRequest(message);

            Assert.AreEqual(MockSecondaryUri.Host, message.Request.Uri.Host);
            Assert.IsTrue(message.TryGetProperty(Constants.GeoRedundantRead.ResourceNotReplicated, out object val) &&
                          (bool)val);
        }