public void HTTPErrorDateTest() { var d = DateTime.Now; HTTPError kek = new HTTPError(404, d); Assert.AreEqual(d, kek.Date); }
static void Main(string[] args) { { float a, b, c, min = -5, max = 5; Console.WriteLine("Enter 3 numbers: "); a = float.Parse(Console.ReadLine()); b = float.Parse(Console.ReadLine()); c = float.Parse(Console.ReadLine()); if ((min < a && a < max) && (min < b && b < max) && (min < c && c < max)) { Console.WriteLine("Numbers are in range"); } else { Console.WriteLine("Numbers are not in range"); } Console.ReadKey(); } { int min, max, i; int[] a = new int[3]; Console.WriteLine("Enter 3 numbers: "); min = a[0]; max = a[0]; for (i = 1; i < 3; i++) { if (a[i] < min) { min = a[i]; } else if (a[i] > max) { max = a[i]; } } Console.WriteLine("min - {0}, max - {1}", min, max); Console.ReadKey(); } { int er; Console.WriteLine("Enter error number"); er = int.Parse(Console.ReadLine()); HTTPError error = (HTTPError)er; Console.WriteLine("Error {0}: {1}", (int)error, error); Console.ReadKey(); } { Dog MyDog; Console.WriteLine("Enter yor dog's name:"); MyDog.Name = Console.ReadLine(); Console.WriteLine("Enter yor dog's mark:"); MyDog.Mark = Console.ReadLine(); Console.WriteLine("Enter yor dog's age:"); MyDog.Age = int.Parse(Console.ReadLine()); Console.WriteLine(MyDog.ToString()); Console.ReadKey(); } }
public void HTTPErrorGetDescriptionOfTest() { Assert.AreEqual(HTTPError.GetDescriptionOf(400), "Bad Request"); Assert.AreEqual(HTTPError.GetDescriptionOf(401), "Unauthorized"); Assert.AreEqual(HTTPError.GetDescriptionOf(403), "Forbidden"); Assert.AreEqual(HTTPError.GetDescriptionOf(402), "Payment Required"); Assert.AreEqual(HTTPError.GetDescriptionOf(404), "Not Found"); }
public void HttpErrorCollectionContainsTest() { var one = new HTTPError(402, DateTime.Now); var collection = new HTTPErrorsCollection(); collection.Add(one); Assert.IsTrue(collection.HttpErrors.Contains(one)); }
public void HTTPErrorDescriptionTest() { HTTPError kek = new HTTPError(); Assert.AreEqual(kek.Description, "ERROR"); HTTPError lol = new HTTPError(404, DateTime.Now); Assert.AreEqual(lol.Description, "Not Found"); }
void OnHTTPError(Exception ex) { var evrgs = new HTTPErrorEventArgs(); evrgs.Exception = ex; if (HTTPError != null) { HTTPError.Invoke(this, evrgs); } }
public void Start() { try { listener.Start(); HandleClientConnections(listener).ConfigureAwait(false); } catch (HttpListenerException ex) { HTTPError?.Invoke(this, new ErrorEventArgs(ex)); } }
public void HttpErrorCollectionClearTest() { var one = new HTTPError(402, DateTime.Now); var two = new HTTPError(403, DateTime.Now); var three = new HTTPError(404, DateTime.Now); var collection = new HTTPErrorsCollection(); collection.Add(one); collection.Add(two); collection.Add(three); collection.Clear(); Assert.IsTrue(collection.HttpErrors.Count == 0); }
public void HttpErrorsGetterTest() { var one = new HTTPError(402, DateTime.Now); var two = new HTTPError(403, DateTime.Now); var three = new HTTPError(404, DateTime.Now); var collection = new HTTPErrorsCollection(); collection.Add(one); collection.Add(two); collection.Add(three); Assert.IsTrue(collection.HttpErrors.Count > 0); Assert.IsTrue(collection[0].Code == 402); }
public void HTTPErrorEqualsTest() { var d = DateTime.Now; HTTPError kek = new HTTPError(401, d); HTTPError lol = new HTTPError(401, d); HTTPError yo = new HTTPError(403, d); HTTPError ye = new HTTPError(403, d); HTTPError kekez = new HTTPError(404, d); HTTPError lolez = new HTTPError(404, d); if (kek.Equals(lol) && yo.Equals(ye) && kekez.Equals(lolez)) { return; } }
public static void ErrorCode(int code) { HTTPError error; if (Enum.IsDefined(typeof(HTTPError), code)) { HTTPError tmp = (HTTPError)code; Console.WriteLine("{0}: {1}", code, tmp.ToString()); } else { Console.WriteLine("Code not found..."); } Console.WriteLine("Return to menu? (y/n)"); GetToMenu(); }
public void HTTPErrorCompareToTest() { var d = DateTime.Now; HTTPError kek = new HTTPError(401, d); try { kek.CompareTo(12); } catch (Exception e) { Assert.AreEqual(e.Message, "об`єкт не є HTTPEror!"); } HTTPError lol = new HTTPError(401, d); HTTPError lolez = new HTTPError(403, d); if (kek.CompareTo(lol) == 0 && kek.CompareTo(lolez) == 1) { return; } }
public static void Run() { HTTPOp.Init(); isRunning = true; SpiderRequest next; while (isRunning) { next = GetNext(); if (next == null) { break; } if (isRunning) { HTTPError err = HTTPOp.Request(next.method, next.Url, next, HttpCallback); if (err != HTTPError.SUCCESS) { Log.Log.log("DNS Error:" + next.Url, Log.Log.ERROR, "Spider.Run"); } } } HTTPOp.StopCore(); }
static void Main(string[] args) { #region Tasks #region Task 1 int day, month; Console.Write("Enter day number: "); day = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter month number: "); month = Convert.ToInt32(Console.ReadLine()); if (day < 31 && month < 12) { Console.WriteLine("True"); } else { Console.WriteLine("False"); } #endregion #region Task 2 Console.Write("Enter number: "); double num = Convert.ToDouble(Console.ReadLine()); double buf = (num - (int)num) * 10; int num1 = (int)buf; int num2 = (int)((buf - num1) * 10); Console.WriteLine("{0}+{1}={2}", num1, num2, num1 + num2); #endregion #region Task 3 int hour = Convert.ToInt32(Console.ReadLine()); if (hour >= 4 && hour < 11) { Console.WriteLine("Good Morning!"); } if (hour >= 11 && hour < 16) { Console.WriteLine("Good Day!"); } if (hour >= 16 && hour < 22) { Console.WriteLine("Good Evening!"); } if ((hour >= 22 && hour < 24) || (hour >= 0 && hour < 4)) { Console.WriteLine("Good Morning!"); } #endregion #region Task 4 TestCaseStatus test1Status = TestCaseStatus.Pass; if (test1Status == TestCaseStatus.Pass) { Console.WriteLine("Passed"); } #endregion #region Task 5 #endregion #endregion #region HomeWork #region Task A double f_num1, f_num2, f_num3; Console.Write("Enter first number: "); f_num1 = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter second number: "); f_num2 = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter third number: "); f_num3 = Convert.ToDouble(Console.ReadLine()); if (f_num1 >= -5 && f_num1 <= 5) { Console.WriteLine("{0} - True", f_num1); } if (f_num2 >= -5 && f_num2 <= 5) { Console.WriteLine("{0} - True", f_num2); } if (f_num3 >= -5 && f_num3 <= 5) { Console.WriteLine("{0} - True", f_num3); } #endregion #region Task B int i_num1, i_num2, i_num3; Console.Write("Enter first number: "); i_num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter second number: "); i_num2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter third number: "); i_num3 = Convert.ToInt32(Console.ReadLine()); if (i_num2 > i_num1) { if (i_num3 > i_num2) { Console.WriteLine("Max = {0}", i_num3); } else { Console.WriteLine("Max = {0}", i_num2); } } else { Console.WriteLine("Max = {0}", i_num1); } if (i_num2 < i_num1) { if (i_num3 < i_num2) { Console.WriteLine("Min = {0}", i_num3); } else { Console.WriteLine("Min = {0}", i_num2); } } else { Console.WriteLine("Min = {0}", i_num1); } #endregion #region Task C HTTPError h = HTTPError.e401; if (h == HTTPError.e401) { Console.WriteLine("Error 401"); } #endregion #region Task D Dog d = new Dog(); d.Name = Console.ReadLine(); d.Mark = Console.ReadLine();; d.Age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(d._toString()); #endregion #endregion }