Exemple #1
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>();
		}
Exemple #2
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);
		}