public void BlinqShouldEqualLinqNativeArrayFirstOrDefaultPredicate([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.FirstOrDefault(source, EqualsZero.Invoke)); var actual = ExceptionAndValue(() => source.FirstOrDefault(EqualsZero)); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeSequenceFirstOrDefault([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.FirstOrDefault(source)); var actual = ExceptionAndValue(() => source.FirstOrDefault()); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
// api/ocr public async Task <IHttpActionResult> Post() { List <Eitem> returnedEitems = new List <Eitem>(); var file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null; if (file.ContentLength > 0) { //Upload Photo OcrService ocrService = new OcrService(); BinaryReader binaryReader = new BinaryReader(file.InputStream); byte[] imageAsByteArray = binaryReader.ReadBytes(file.ContentLength); var json = await ocrService.GetOrcServerResponce(imageAsByteArray); //Deserialize Json var ocrDto = JsonConvert.DeserializeObject <OcrDto>(json); if (ocrDto.ErrorMessage != null || String.IsNullOrEmpty(Enumerable.FirstOrDefault(ocrDto.ParsedResults).ParsedText)) { return(BadRequest(ocrDto.ErrorMessage.ToString())); } //parse E string parsedText = Regex.Replace(ocrDto.ParsedResults[0].ParsedText, @"\s+", ""); var eElements = Enumerable.Cast <Match>(Regex.Matches(parsedText, "(([Е{IsCyrillic}]{1}[0-9]{3,4})|([E{IsCyrillic}-]{2}[0-9]{3,4}))")).Select(m => m.Value.Unidecode()).ToList(); //Get current E from MemoryCache MemoryCasheService memoryCache = new MemoryCasheService(); var items = memoryCache.GetValue("ALL_EITEMS") as List <Eitem>; if (items != null) { returnedEitems = items.Where(item => eElements.Contains(item.Ecode)).ToList(); } return(Ok(returnedEitems)); } else { return(BadRequest()); } }
/// <inheritdoc /> protected override bool SkipMethod(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, out string skipReason) { skipReason = null; var runIntegrationTests = discoveryOptions.GetValue <bool>(nameof(ElasticXunitRunOptions.RunIntegrationTests)); if (!runIntegrationTests) { return(true); } var cluster = TestAssemblyRunner.GetClusterForClass(testMethod.TestClass.Class); if (cluster == null) { skipReason += $"{testMethod.TestClass.Class.Name} does not define a cluster through IClusterFixture or {nameof(IntegrationTestClusterAttribute)}"; return(true); } var elasticsearchVersion = discoveryOptions.GetValue <ElasticVersion>(nameof(ElasticXunitRunOptions.Version)); // Skip if the version we are testing against is attributed to be skipped do not run the test nameof(SkipVersionAttribute.Ranges) var skipVersionAttribute = Enumerable.FirstOrDefault(GetAttributes <SkipVersionAttribute>(testMethod)); if (skipVersionAttribute != null) { var skipVersionRanges = skipVersionAttribute.GetNamedArgument <IList <SemVer.Range> >(nameof(SkipVersionAttribute.Ranges)) ?? new List <SemVer.Range>(); if (elasticsearchVersion == null && skipVersionRanges.Count > 0) { skipReason = $"{nameof(SkipVersionAttribute)} has ranges defined for this test but " + $"no {nameof(ElasticXunitRunOptions.Version)} has been provided to {nameof(ElasticXunitRunOptions)}"; return(true); } if (elasticsearchVersion != null) { var reason = skipVersionAttribute.GetNamedArgument <string>(nameof(SkipVersionAttribute.Reason)); for (var index = 0; index < skipVersionRanges.Count; index++) { var range = skipVersionRanges[index]; // inrange takes prereleases into account if (!elasticsearchVersion.InRange(range)) { continue; } skipReason = $"{nameof(SkipVersionAttribute)} has range {range} that {elasticsearchVersion} satisfies"; if (!string.IsNullOrWhiteSpace(reason)) { skipReason += $": {reason}"; } return(true); } } } var skipTests = GetAttributes <SkipTestAttributeBase>(testMethod) .FirstOrDefault(a => a.GetNamedArgument <bool>(nameof(SkipTestAttributeBase.Skip))); if (skipTests == null) { return(false); } skipReason = skipTests.GetNamedArgument <string>(nameof(SkipTestAttributeBase.Reason)); return(true); }
public static TSource FirstOrDefault <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate) => LinqEnumerable.FirstOrDefault(source, predicate);
public static TSource FirstOrDefault <TSource>(this IEnumerable <TSource> source) => LinqEnumerable.FirstOrDefault(source);
/// <summary> /// Finds the LeadQualification entity within the LeadQualication collection that matches the Qualification. /// </summary> /// <param name="qualication">The Qualifiation.</param> /// <param name="leadQualifications">The LeadQualifications.</param> /// <returns></returns> protected static ILeadQualification FindLeadQualification(IQualification qualication, IList <ILeadQualification> leadQualifications) { return(Enumerable.FirstOrDefault(leadQualifications, leadQual => leadQual.Qualification.Equals(qualication))); }