示例#1
0
        public void ShouldBeNotAbleToFindElementByIdWhenComparerIsSubClassOfStringComparer()
        {
            // GIVEN
            var endsWithComparer = new EndsWithComparer("myId");
            var byID             = Find.ById(endsWithComparer);

            // WHEN
            var hinter = IdHinter.GetIdHint(byID);

            // THEN
            Assert.That(hinter, Is.Null);
        }
示例#2
0
        public void ShouldBeNotAbleToFindElementByIdWhenComparerIsSubClassOfStringComparer()
        {
            // GIVEN
            var endsWithComparer = new EndsWithComparer("myId");
            var byID = Find.ById(endsWithComparer);
            
            // WHEN
            var hinter = IdHinter.GetIdHint(byID);

            // THEN
            Assert.That(hinter, Is.Null);
        }
        private Task CopySolutionAsync(SolutionRewriteContext context, SolutionExplorer sourceExplorer, string destinationPath)
        {
            Log.Debug($"Copying solution from  \"{sourceExplorer.SolutionPath}\" to \"{destinationPath}\".");
            context.CancellationToken.ThrowIfCancellationRequested();

            var endsWithComparer = new EndsWithComparer();
            var blackList        = Configuration.GetFileCopyBlackListElements().Select(s => s.TrimStart('*')).ToImmutableHashSet();
            var sourceFiles      = new HashSet <string>(
                sourceExplorer
                .GetAllReferencedDocuments()
                .Concat(sourceExplorer.GetAllAdditiontalDocuments())
                .Concat(sourceExplorer.GetAllProjectFiles())
                .Concat(new [] { sourceExplorer.SolutionPath })
                );

            foreach (var sourceFile in sourceFiles)
            {
                if (context.CancellationToken.IsCancellationRequested)
                {
                    return(Task.CompletedTask);
                }

                var relativePath = GetRelativePath(SolutionPath, sourceFile);
                var destFileName = Path.Combine(destinationPath, relativePath);
                var fileInfo     = new FileInfo(destFileName);
                if (blackList.Contains(fileInfo.Name, endsWithComparer))
                {
                    continue;
                }

                if (!fileInfo.Directory.Exists)
                {
                    fileInfo.Directory.Create();
                }
                File.Copy(sourceFile, destFileName);
            }

            return(Task.CompletedTask);
        }