public void ResolvedWithOkTypeAndErrType_UnwrapValue() { Resolved <bool, string> resolved = Resolved.Ok(true); var value = resolved.Unwrap(); Assert.IsTrue(value); }
public void ResolvedWithIntegerOk_UnwrapValue() { Resolved <int> resolved = Resolved.Ok(5); var value = resolved.Unwrap(); Assert.AreEqual(5, value); }
static Resolved GetOrAdd(FieldType fieldType) { return(cache.GetOrAdd( fieldType.ResolvedType, graphType => { var resolved = new Resolved(); if (graphType is ListGraphType listGraphType) { graphType = listGraphType.ResolvedType; } if (graphType is NonNullGraphType nonNullGraphType) { graphType = nonNullGraphType.ResolvedType; } if (graphType is IComplexGraphType complexType) { resolved.ComplexGraphType = complexType; } resolved.EntityType = ResolvedEntityType(graphType); return resolved; })); }
public void DifferentTypeChainedResolvedOk_ResolvedValueIsTrue() { Resolved resolved = Resolved.Ok(); var r = resolved .Match <Resolved <int> >( Ok: () => Resolved.Ok(1), Err: (err) => Resolved.Err(err) ) .Match <Resolved>( Ok: (n) => Resolved.Ok(), Err: (err) => Resolved.Err(err) ) .Match <Resolved <bool> >( Ok: () => Resolved.Ok(true), Err: (err) => Resolved.Err(err) ); Assert.IsTrue(r.IsOk); r.Match( Ok: (value) => { Assert.IsTrue(value); }, Err: (err) => { Assert.Fail("Unexpected error occurred"); } ); }
public void ResolvedWithDefaultErr_ForwardErrThroughTheChain() { string errorMessage = "Forwarded Err"; Resolved resolved = Resolved.ErrAsIEnumerable(new Exception(errorMessage)); var result = resolved .Match( Ok: () => Resolved.Ok(), Err: Behavior.Forward ) .Match( Ok: () => Resolved.Ok(), Err: Behavior.Forward ) .Match <int>( Ok: () => Resolved.Ok(1), Err: Behavior.Forward ); Assert.AreEqual(typeof(Err), result.Value.GetType()); var err = (Err)result.Value; Assert.AreEqual(err.Value.First().Message, errorMessage); }
public void NestedResolved_ReturnsResolvedOkWithIntValue() { Resolved <int> innerResolved = Resolved.Ok(1); Resolved <Resolved <int> > resolved = Resolved.Ok(innerResolved); var result = resolved.Match <Resolved <int> >( Ok: (r) => { var number = r.Match( Ok: (n) => 1, Err: (err) => 0 ); return(Resolved.Ok(number)); }, Err: (err) => Resolved.Err(err) ); Assert.IsTrue(result.IsOk); result.Match( Ok: (n) => Assert.AreEqual(1, n), Err: (err) => Assert.Fail("Unexpected error occurred") ); }
public IHttpActionResult PutResolved(int id, Resolved resolved) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != resolved.Id) { return(BadRequest()); } db.Entry(resolved).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ResolvedExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void SameTypeChainedResolvedOk_ReturnsLastNumberInTheChain() { Resolved <int> resolved = Resolved.Ok(0); var r = resolved .Match <Resolved <int> >( Ok: (n) => Resolved.Ok(1), Err: (err) => Resolved.Err(err) ) .Match <Resolved <int> >( Ok: (n) => Resolved.Ok(2), Err: (err) => Resolved.Err(err) ) .Match <Resolved <int> >( Ok: (n) => Resolved.Ok(3), Err: (err) => Resolved.Err(err) ); Assert.IsTrue(r.IsOk); r.Match( Ok: (n) => { Assert.AreEqual(3, n); }, Err: (err) => { Assert.Fail("Unexpected error occurred"); } ); }
public void ResolvedWithDefaultErr_IsErrEqualsTrue() { IEnumerable <Exception> errors = new List <Exception>(); Resolved resolved = Resolved.Err(errors); Assert.IsTrue(resolved.IsErr); }
public void ResolvedWithStringErr_ForwardErrThroughTheChain() { string errorMessage = "Forwarded Err"; Resolved <string, string> resolved = Resolved.Err(errorMessage); var result = resolved .Match <int>( Ok: (innerValue) => Resolved.Ok(1), Err: Behavior.Forward ) .Match <bool>( Ok: (innerValue) => Resolved.Ok(true), Err: Behavior.Forward ) .Match <char>( Ok: (innerValue) => Resolved.Ok('\a'), Err: Behavior.Forward ) .Match( Ok: (innerValue) => Resolved.Ok('\b'), Err: Behavior.Forward ); Assert.AreEqual(typeof(Err <string>), result.Value.GetType()); var err = (Err <string>)result.Value; Assert.AreEqual(err.Value, errorMessage); }
public override FullNamedExpression Resolve(ParseContext rc) { if (Resolved != null || Name == null) { return(Resolved); } if (rc == null) { return(null); } base.Resolve(rc); if (Resolved == null) { Name = null; return(null); } if (Resolved is TypeExpression) { Resolved = Resolved.ResolveAsBaseTerminal(rc, false); } return(Resolved); }
public void ResolvedWithDefaultErr_IsOkEqualsFalse() { IEnumerable <Exception> err = new List <Exception>(); Resolved resolved = Resolved.Err(err); Assert.IsFalse(resolved.IsOk); }
public void DifferentTypeChainedResolvedErr_ResolvedValueIsString() { IEnumerable <Exception> errors = new Exception[0]; Resolved resolved = Resolved.Err(errors); var r = resolved .Match <Resolved <bool> >( Ok: () => Resolved.Ok(true), Err: (err) => Resolved.Err(err) ) .Match <Resolved <int, string> >( Ok: (b) => Resolved.Ok(1), Err: (err) => Resolved.Err("Erro") ); Assert.IsTrue(r.IsErr); r.Match( Ok: (n) => { Assert.Fail("Unexpected error occurred"); }, Err: (err) => { Assert.AreEqual(typeof(string), err.GetType()); Assert.AreEqual("Erro", err); } ); }
public void ResolvedWithDefaultErr_UnwrapValueThrowsException() { Resolved <int> resolved = Resolved.ErrAsIEnumerable(new Exception()); Assert.Throws(typeof(InvalidOperationException), () => resolved.Unwrap()); }
public void Lookup() { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_Url.Replace("ssdp", "environment")); request.Accept = "application/json"; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { var serializer = new JsonSerializer(); using (var sr = new StreamReader(response.GetResponseStream())) using (var jsonTextReader = new JsonTextReader(sr)) { EnvironmentModel Model = (EnvironmentModel)serializer.Deserialize(jsonTextReader, typeof(EnvironmentModel)); string IPWithPort = m_IpAddress.Address + ((m_IpAddress.Port != 80) ? ":" + m_IpAddress.Port : ""); Resolved?.Invoke(this, new DataGridRow() { Name = Model.machineName, Url = "http://" + IPWithPort + "/", IpAddress = IPWithPort, Location = Model.location }); } } } catch (WebException) { LookupLegacy(); } catch (Exception) { Errored?.Invoke(this, m_Url); } }
public void ResolvedWithBoolErr_UnwrapValueThrowsException() { Resolved <int, bool> resolved = Resolved.Err(true); Assert.Throws(typeof(InvalidOperationException), () => resolved.Unwrap()); }
public override String ToString() { if (Protocol.Equals(TcpProtocol)) { if (Resolved != null) { return(Resolved.ToString()); } } else if (Protocol.Equals(IpcProtocol)) { if (Resolved != null) { return(Resolved.ToString()); } } else if (Protocol.Equals(PgmProtocol)) { if (Resolved != null) { return(Resolved.ToString()); } } if (!string.IsNullOrEmpty(Protocol) && !string.IsNullOrEmpty(AddressString)) { return(Protocol + "://" + AddressString); } return(null); //TODO: REVIEW - Although not explicitly prohibited, returning null from ToString seems sketchy; return string.Empty? }
public override int GetHashCode() { unchecked { return(New.GetHashCode() ^ Open.GetHashCode() ^ Resolved.GetHashCode() ^ OnHold.GetHashCode() ^ Invalid.GetHashCode() ^ Duplicate.GetHashCode() ^ Wontfix.GetHashCode()); } }
private void EnableButtons() { if (Module.InTheMiddleOfRebase()) { if (Height < 200) { Height = 500; } Branches.Enabled = false; Ok.Enabled = false; chkStash.Enabled = false; AddFiles.Enabled = true; Commit.Enabled = true; Resolved.Enabled = !Module.InTheMiddleOfConflictedMerge(); Mergetool.Enabled = Module.InTheMiddleOfConflictedMerge(); Skip.Enabled = true; Abort.Enabled = true; } else { Branches.Enabled = true; Ok.Enabled = true; AddFiles.Enabled = false; Commit.Enabled = false; Resolved.Enabled = false; Mergetool.Enabled = false; Skip.Enabled = false; Abort.Enabled = false; chkStash.Enabled = Module.IsDirtyDir(); } SolveMergeconflicts.Visible = Module.InTheMiddleOfConflictedMerge(); Resolved.Text = _continueRebaseText.Text; Mergetool.Text = _solveConflictsText.Text; Resolved.ForeColor = SystemColors.ControlText; Mergetool.ForeColor = SystemColors.ControlText; ContinuePanel.BackColor = Color.Transparent; MergeToolPanel.BackColor = Color.Transparent; var highlightColor = Color.Yellow.AdaptBackColor(); if (Module.InTheMiddleOfConflictedMerge()) { AcceptButton = Mergetool; Mergetool.Focus(); Mergetool.Text = _solveConflictsText2.Text; MergeToolPanel.BackColor = highlightColor; } else if (Module.InTheMiddleOfRebase()) { AcceptButton = Resolved; Resolved.Focus(); Resolved.Text = _continueRebaseText2.Text; ContinuePanel.BackColor = highlightColor; } }
protected override void InnerExecute() { foreach (var slaveCommand in _slaveCommands) { slaveCommand.Execute(Resolved); } Resolved.Persist(); }
public ActionResult DeleteConfirmed(int id) { Resolved resolved = db.Resolveds.Find(id); db.Resolveds.Remove(resolved); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddAsset(Hash128 guid, Hash128 targetHash, AssetObjectManifest manifest, AssetBundle assetBundle) { _Assets[guid] = new Resolved { AssetObjectManifest = manifest, AssetBundle = assetBundle, TargetHash = targetHash }; }
public ActionResult Edit([Bind(Include = "Id,DeviceId,SuspiciousActivites,_Date,TimeResolved,Verdict, StoreName, StoreLocation")] Resolved resolved) { if (ModelState.IsValid) { db.Entry(resolved).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resolved)); }
public ActionResult Edit([Bind(Include = "Id,DeviceId,Department,ThreatLevel,TimeOccured,TimeResolved,Verdict")] Resolved resolved) { if (ModelState.IsValid) { db.Entry(resolved).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resolved)); }
public ActionResult Create([Bind(Include = "Id,DeviceId,Department,ThreatLevel,TimeOccured,TimeResolved,Verdict")] Resolved resolved) { if (ModelState.IsValid) { db.Resolveds.Add(resolved); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resolved)); }
private async void AddResolvedIncident(Resolved resolved_incident) { //var httpClient = new HttpClient(); //var byteArray = Encoding.ASCII.GetBytes("TeamMeijer:Need Anything?"); //var header = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); //httpClient.DefaultRequestHeaders.Authorization = header; string json_object = JsonConvert.SerializeObject(resolved_incident); var content = new StringContent(json_object, Encoding.UTF8, "application/json"); await App.httpClient.PostAsync("https://rsml.azurewebsites.net/api/Resolveds1", content); }
public void ResolvedErrWithNullValue_ArgumentNullException() { Resolved resolved = Resolved.Err(null); Assert.Throws( typeof(ArgumentNullException), () => resolved.Match( Ok: () => true, Err: (err) => true )); }
public void ErrAsIEnumerable_ReturnsResolvedWithDefaultErr() { Resolved resolved = Resolved.ErrAsIEnumerable(new Exception()); Assert.IsTrue(resolved.IsErr); resolved.Match( Ok: () => Assert.Fail("Unexpected error"), Err: (err) => Assert.IsTrue(err.GetType().GetInterfaces().Contains(typeof(IEnumerable <Exception>))) ); }
public ActionResult Create([Bind(Include = "Id,DeviceId,SuspiciousActivites,_Date,TimeResolved,Verdict, StoreName, StoreLocation")] Resolved resolved) { if (ModelState.IsValid) { db.Resolveds.Add(resolved); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resolved)); }
public IHttpActionResult GetResolved(int id) { Resolved resolved = db.Resolveds.Find(id); if (resolved == null) { return(NotFound()); } return(Ok(resolved)); }