예제 #1
0
        private async Task <IEnumerable <TResult> > AnonymizeAsync(List <TSource> batchData, IProgress <BatchAnonymizeProgressDetail> progress, CancellationToken cancellationToken)
        {
            return(await Task.Run(async() =>
            {
                List <TResult> result = new List <TResult>();

                BatchAnonymizeProgressDetail batchAnonymizeProgressDetail = new BatchAnonymizeProgressDetail();
                batchAnonymizeProgressDetail.CurrentThreadId = Thread.CurrentThread.ManagedThreadId;

                foreach (TSource content in batchData)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        throw new OperationCanceledException();
                    }

                    TResult anonymizedResult = await AnonymizerFunctionAsync(content);
                    if (EmptyElement.IsEmptyElement(anonymizedResult))
                    {
                        batchAnonymizeProgressDetail.ProcessSkipped++;
                    }
                    else
                    {
                        batchAnonymizeProgressDetail.ProcessCompleted++;
                    }
                    result.Add(anonymizedResult);
                }

                progress?.Report(batchAnonymizeProgressDetail);
                return result;
            }).ConfigureAwait(false));
        }
        public void GivenNonEmptyElementJson_WhenCheckIFEmptyElement_ResultShouldBeFalse(string file)
        {
            var json = File.ReadAllText(Path.Join("TestResources", file));

            Assert.False(EmptyElement.IsEmptyElement(json));
            Assert.False(EmptyElement.IsEmptyElement((object)json));
        }
        public void GivenNonEmptyElement_WhenCheckIFEmptyElement_ResultShouldBeFalse(string file)
        {
            var json    = File.ReadAllText(Path.Join("TestResources", file));
            var element = _parser.Parse <Resource>(json).ToTypedElement();

            Assert.False(EmptyElement.IsEmptyElement(json));
            Assert.False(EmptyElement.IsEmptyElement((object)json));
        }
 public void GivenNonEmptyElemetContent_WhenCheckIFEmptyElement_ResultShouldBeFalse(string content)
 {
     Assert.False(EmptyElement.IsEmptyElement(content));
     Assert.False(EmptyElement.IsEmptyElement((object)content));
 }