CreateRequestBuilder_WithNotHttpUri_ShouldThrow( HttpRequestBuilderFactory sut) { //arrange var uri = new Uri("protocol://path"); //act Action action = () => sut.CreateRequestBuilder(uri); //assert action.ShouldThrow<ArgumentException>(); }
public void CreateRequestBuilder_ShouldReturnCorrectValue( HttpRequestBuilderFactory sut, Uri uri) { //arrange //act var actual = sut.CreateRequestBuilder(uri); //assert actual.Should().BeOfType<HttpRequestBuilderOptions>(); }
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>(); }
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); }