public void op_Load_string() { var buffer = new StringBuilder(); buffer.AppendLine(">request>"); buffer.AppendLine("GET http://example.com/ HTTP/1.1"); buffer.AppendLine("<response<"); buffer.AppendLine("HTTP/1.1 200 OK"); buffer.AppendLine("<<"); buffer.AppendLine(string.Empty); buffer.AppendLine("# a comment"); buffer.AppendLine(string.Empty); buffer.AppendLine(">request>"); buffer.AppendLine("GET http://example.net/ HTTP/1.1"); buffer.AppendLine("<response<"); buffer.AppendLine("HTTP/1.1 303 See Other"); buffer.AppendLine("Location: http://example.net/index.html"); buffer.AppendLine("<<"); var obj = HttpExpectations.Load(buffer.ToString()); Assert.IsAssignableFrom <IHttpExpectations>(obj); var first = obj.First(); Assert.Equal("GET http://example.com/ HTTP/1.1", first.Exchange.Request.Line); Assert.Equal("HTTP/1.1 200 OK", first.Exchange.Response.Line); var last = obj.Last(); Assert.Equal("GET http://example.net/ HTTP/1.1", last.Exchange.Request.Line); Assert.Equal("HTTP/1.1 303 See Other", last.Exchange.Response.Line); Assert.Equal("http://example.net/index.html", last.Exchange.Response.Headers["Location"]); }
public void op_Load_stringEmpty() { Assert.Throws <ArgumentOutOfRangeException>(() => HttpExpectations.Load(string.Empty)); }
public void op_Load_FileInfo(string name) { Assert.True(HttpExpectations.Load(new FileInfo(name)).Result); }
public void op_Load_FileInfoNull() { Assert.Throws <ArgumentNullException>(() => HttpExpectations.Load(null as FileInfo)); }
public void op_Load_stringNull() { Assert.Throws <ArgumentNullException>(() => HttpExpectations.Load(null as string)); }