public void Returns_status_not_null() { const string statusUrl = "http://statusurl.no"; const string statusQueryToken = "StatusQueryToken"; var actual = new StatusUrl(new Uri(statusUrl)); Assert.NotNull(actual.Status(statusQueryToken)); }
public static JobResponse GetDirectJobResponse() { var jobId = 123456789; var jobReference = "senders-reference"; var signers = GetResponseSigners(); var statusUrl = new StatusUrl(new Uri("http://statusurl.no")); return(new JobResponse( jobId, jobReference, signers, statusUrl )); }
/// <summary></summary> public override int GetHashCode() { var code = 13; // Calculate hash on each properties one by one code = (code * 7) + Id.GetHashCode(); if (CreationTime != null) { code = (code * 7) + CreationTime.GetHashCode(); } if (this.ActionTypeUrl != null) { code = (code * 7) + ActionTypeUrl.GetHashCode(); } if (this.ActionType != null) { code = (code * 7) + ActionType.GetHashCode(); } code = (code * 7) + Discarded.GetHashCode(); if (this.StatusUrl != null) { code = (code * 7) + StatusUrl.GetHashCode(); } if (this.Status != null) { code = (code * 7) + Status.GetHashCode(); } if (this.ErrorString != null) { code = (code * 7) + ErrorString.GetHashCode(); } if (this.User != null) { code = (code * 7) + User.GetHashCode(); } if (this.ObjectUrl != null) { code = (code * 7) + ObjectUrl.GetHashCode(); } if (this.AnnotationsUrl != null) { code = (code * 7) + AnnotationsUrl.GetHashCode(); } if (this.Self != null) { code = (code * 7) + Self.GetHashCode(); } return(code); }
private async Task <CommitStatusResponse> PostMessage(CommitStatus status, CancellationToken token = default(CancellationToken)) { var data = status.ToJson(); var buffer = Encoding.UTF8.GetBytes(data); //var url = NetPath.Combine(StatusUrl, Sha); var url = StatusUrl.Replace("{sha}", Sha); var request = WebRequest.CreateHttp(url); request.Method = "POST"; request.KeepAlive = false; request.ContentType = "application/json"; request.ContentLength = buffer.Length; request.UserAgent = "Photon.Server"; var hasUsername = !string.IsNullOrEmpty(Username); var hasPassword = !string.IsNullOrEmpty(Password); if (hasUsername || hasPassword) { var encoding = Encoding.GetEncoding("ISO-8859-1"); var authBuffer = encoding.GetBytes($"{Username}:{Password}"); var authString = Convert.ToBase64String(authBuffer); request.Headers.Add("Authorization", $"Basic {authString}"); } using (token.Register(() => request.Abort())) { using (var requestStream = request.GetRequestStream()) { await requestStream.WriteAsync(buffer, 0, buffer.Length, token); } using (var response = (HttpWebResponse)await request.GetResponseAsync()) using (var responseStream = response.GetResponseStream()) { if (responseStream == null) { return(null); } using (var reader = new StreamReader(responseStream)) using (var jsonReader = new JsonTextReader(reader)) { return(JsonSettings.Serializer.Deserialize <CommitStatusResponse>(jsonReader)); } } } }
/// <summary> /// Статус камеры /// </summary> /// <param name="Id">Идентификатор камеры</param> /// <returns></returns> public ActionResult StatusCamera(int?Id) { if (Id == null) { throw new HttpException(400, "Некорректный запрос"); } // получения сведений о камере General Camera = db.TGeneral.Find(Id); if (Camera == null) { throw new HttpException(400, "Некорректный запрос"); } StatusUrl statusUrl = new StatusUrl(Camera.CameraImgLink, Camera.CameraAuthUser, Camera.CameraAuthPassword); ViewBag.Status = statusUrl.Status(); return(View("_StatusUrl")); }
public void Can_be_initialized_with_null_string_throws_on_status_url() { var actual = new StatusUrl(null); Assert.Throws <InvalidOperationException>(() => actual.StatusBaseUrl); }