public void ResponseBuilder_returns_500_error_on_empty_data() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); var rb = new ResponseBuilder(r); rb.Response.Data = null; rb.GetResponseBytes(); Assert.AreEqual(500, rb.Response.HttpResponseCode, "On nulled data response didn't have 500 Error"); }
public void Has_Accept_range_bytes() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.AcceptsRanges = true; var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains("Accept-Ranges: bytes"), "Accept range was not set"); }
public void Has_ContentEncoding_tag() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.ContentEncoding = "gzip"; var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains("Content-Encoding: " + r.ContentEncoding)); }
public static Response CreateSampleResponse() { //create sample data for Response var data = Encoding.UTF8.GetBytes("This is just a test data!"); //create Response var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); return r; }
public void Has_LastModified_tag() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.LastModified = DateTime.Now; var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains("Last-Modified: " + string.Format("{0:r}", r.LastModified))); }
public void Has_ConnectionStatus_when_it_is_set() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.ConnectionStatus = "close"; var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains("Connection: close")); }
public void Creates_heading_HTTP_version() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Exists(h => h.Contains(WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10) || h.Contains(WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion11))); }
/// <summary> /// Constructor /// </summary> public ResponseBuilder(Response response) { _response = response; }
public void Has_Set_Cookie_tag() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.Cookies.Add("test", "cookie"); var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains(string.Format("Set-Cookie: {0}={1}", "test", "cookie"))); }
public void Has_Location_tag() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); r.Location = "/"; var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains("Location: " + r.Location)); }
public void Http_code_status_is_200_by_default() { Response target = new Response(); const int data = 200; Assert.AreEqual(target.HttpResponseCode, data); }
public void HTTPVersion_is_1_0_by_default() { Response target = new Response(); const string version = "HTTP/1.0"; Assert.AreEqual(target.HttpVersion, version); }
public void Returns_more_than_1_item() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Count > 0); }
public void Is_not_null() { var r = new Response(); var hc = new ResponseHeaderCreator(r); Assert.IsNotNull(hc); }
public void Has_Set_Cookie_tag_with_Expired_and_Path() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); var expirationDate = DateTime.Now.AddDays(2); var c = new Cookie("test", "cookie"); c.Expires = expirationDate; c.Path = "/"; r.Cookies.Add(c); var hc = new ResponseHeaderCreator(r); var headers = hc.Create(); Assert.IsTrue(headers.Contains(string.Format(CultureInfo.InvariantCulture, "Set-Cookie: {0}={1}; Path={2}; Expires={3:r}", "test", "cookie", c.Path, expirationDate))); }
public void ResponseConstructorTest() { Response target = new Response(); Assert.IsTrue(target != null, "Response can't be created"); }
public void ResponseBuilder_can_be_created() { var r = new Response("text/html", WebServer.BusinessLogic.Helpers.WebserverConstants.HttpVersion10, data); var rb = new ResponseBuilder(r); Assert.IsTrue(rb != null, "ResponseBuilder was not created properly"); }
public void Data_is_null_on_creation_of_Response() { Response target = new Response(); Assert.AreEqual(target.Data, null); }
public void Http_code_description_is_OK_by_default() { Response target = new Response(); const string data = "OK"; Assert.AreEqual(target.HttpResponseCodeDescription, data); }