示例#1
0
        public void CreateRequestBuilder_ShouldReturnCorrectValue(
            HttpRequestBuilderFactory sut,
            Uri uri)
        {
            //arrange

            //act
            var actual = sut.CreateRequestBuilder(uri);

            //assert
            actual.Should().BeOfType <HttpRequestBuilderOptions>();
        }
示例#2
0
        CreateRequestBuilder_WithNotHttpUri_ShouldThrow(
            HttpRequestBuilderFactory sut)
        {
            //arrange
            var uri = new Uri("protocol://path");

            //act
            Action action = () => sut.CreateRequestBuilder(uri);

            //assert
            action.ShouldThrow <ArgumentException>();
        }
示例#3
0
        public void Execute_WithInvalidUri_ShouldThrow(string path)
        {
            //arrange
            var builder        = new HttpRequestBuilder();
            var builderFactory = new HttpRequestBuilderFactory();

            var request = builderFactory.CreateRequestBuilder(new Uri("http://www.bing.com"))
                          .Get()
                          .AppendPath(path)
                          .Parameter("q", "test")
                          .ToRequest(builder);

            //act
            Func <Task> action = async() => await request.Execute(CancellationToken.None);

            //assert
            action.ShouldThrow <HttpRequestSuccessException>();
        }
示例#4
0
        public async Task Execute_ShouldReturnCorrectValue()
        {
            //arrange
            var builder        = new HttpRequestBuilder();
            var builderFactory = new HttpRequestBuilderFactory();

            var request = builderFactory.CreateRequestBuilder(new Uri("http://www.bing.com"))
                          .Get()
                          .AppendPath("search")
                          .Parameter("q", "test")
                          .ToRequest(builder);

            //act
            var result = await request.Execute(new CancellationToken());

            //assert
            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
示例#5
0
 public void Sut_ShouldBeHttpRequestBuilderFactory(HttpRequestBuilderFactory sut)
 {
     sut.Should().BeAssignableTo <IHttpRequestBuilderFactory>();
 }