예제 #1
0
			CreateRequestBuilder_WithNotHttpUri_ShouldThrow(
			HttpRequestBuilderFactory sut)
		{
			//arrange
			var uri = new Uri("protocol://path");

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

			//assert
			action.ShouldThrow<ArgumentException>();
		}
예제 #2
0
		public void CreateRequestBuilder_ShouldReturnCorrectValue(
		  HttpRequestBuilderFactory sut,
			Uri uri)
		{
			//arrange

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

			//assert
			actual.Should().BeOfType<HttpRequestBuilderOptions>();
		}
예제 #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);
		}