コード例 #1
0
        public void when_filtering_then_string_is_encoded_for_request()
        {
            //Given
            var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.NotImplemented));
            var httpClient             = new HttpClient(fakeHttpMessageHandler);

            var servant = new AzureTableClient(Substitute.For <IAzureStorageHandler>(), httpClient);
            var content = "test string '/?:@&=+,$ end test";

            //When
            var result = servant.GetEncodedFilterPropertyValue(content);

            //Then
            result.Equals("test%20string%20''%2F%3F%3A%40%26%3D%2B%2C%24%20end%20test");
        }
コード例 #2
0
        public async Task when_put_blob_request_then_response_should_be_ok()
        {
            //Given

            var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.OK));
            var httpClient             = new HttpClient(fakeHttpMessageHandler);

            var apiHandler = Substitute.For <IAzureStorageHandler>();

            apiHandler.GetRequest(Arg.Is(StorageType.Blob), Arg.Is(HttpMethod.Put), Arg.Any <string>(), Arg.Any <byte[]>()).Returns(
                x => { return(new HttpRequestMessage(HttpMethod.Put, "http://www.justafake.com/something")); }
                );
            var servant = new AzureBlobClient(apiHandler, httpClient);
            var content = Encoding.UTF8.GetBytes("arandomstring");

            //When
            var result = await servant.PutBlobAsync("test", "test.jpg", content);

            //Then
            result.Equals(true);
        }