/// <summary> /// Performs data access without exlicitly promising that there will be a string to return /// </summary> /// <param name="key">Key of the mapping to be found</param> /// <returns>An option of string</returns> private IOption <string> AccessData(int key) { if (_data.TryGetValue(key.ToString(), out var result)) { return(Some <string> .Create(result)); } return(None <string> .Create()); }
private Either <string, Some <TTestResponse> > RequestServer <TTestResponse>(string subUrl) where TTestResponse : new() { return(RestClient.Bind(client => { var request = new RestRequest(subUrl); var response = client.Execute <TTestResponse>(request); if (response.StatusCode == HttpStatusCode.OK) { return Prelude.Right <string, Some <TTestResponse> >(Some.Create(response.Data)); } return Prelude.Left <string, Some <TTestResponse> >(string.IsNullOrEmpty(response.Content) ? response.ErrorMessage : response.Content); })); }
private Option <TestBuildResult> GetBuildTestResult(string buildName, TestsReponse testsResponse) { IEnumerable <TestResult> failedTests = testsResponse.TestOccurrence.Map(TestResult.FromSingleTestResponse).Filter(TestResult.GetIsFailed); if (failedTests.Any() && !buildName.Contains("Cyrillic")) { return(Some.Create(new TestBuildResult { BuildName = buildName, TestResults = Prelude.toList(failedTests) })); } return(Option <TestBuildResult> .None); }