예제 #1
0
        public override IEnumerable<PvcStream> Execute(IEnumerable<PvcStream> inputStreams)
        {
            var resultStreams = new List<PvcStream>();

            foreach (var inputStream in inputStreams)
            {
                ZipFile zip = ZipFile.Read(inputStream);

                foreach (ZipEntry e in zip)
                {
                    var outputStream = new ZipMemoryStream();

                    if (!String.IsNullOrEmpty(_password))
                    {
                        e.Password = _password;
                    }

                    e.Extract(outputStream);
                    var resultStream = new PvcStream(() => outputStream);
                    resultStream.Tags.Add("unzipped");
                    resultStreams.Add(resultStream.As(e.FileName));
                }
            };

            return resultStreams;
        }
예제 #2
0
        public override IEnumerable<PvcStream> Execute(IEnumerable<PvcStream> inputStreams)
        {
            //Not using .Any() to avoid multiple enumeration and to avoid converting the enumerable to list. Using good old bool set check.
            var hasAnyStream = false;

            var copyToStream = new MemoryStream();

            foreach (var inputStream in inputStreams)
            {
                hasAnyStream = true;
                inputStream.Position = 0;
                inputStream.CopyTo(copyToStream);
            }
            if (!hasAnyStream)
            {
                return Enumerable.Empty<PvcStream>();
            }
            var returnStream = new PvcStream(() => copyToStream)
            {
                Position = 0
            };

            return new[]
            {
                returnStream.As(_resultName)
            };
        }
예제 #3
0
        public static string StreamToTempFile(PvcStream stream)
        {
            // be sure to start from beginning
            stream.Position = 0;

            var tmpFileName = Path.GetTempFileName();

            File.WriteAllText(tmpFileName, new StreamReader(stream).ReadToEnd());

            return(tmpFileName);
        }
예제 #4
0
        private void RunAllUnitTests(PvcStream stream)
        {
            Console.WriteLine("Testing: " + stream.OriginalSourcePath);
            var testAssembly = Assembly.Load(File.ReadAllBytes(stream.OriginalSourcePath));

            var package = new TestPackage(testAssembly.GetName().FullName);
            TestExecutionContext.CurrentContext.TestPackage = package;

            var builder = new NamespaceTreeBuilder(new TestAssembly(testAssembly, testAssembly.GetName().FullName));
            var fixtures =
                testAssembly.GetTypes()
                    .Where(TestFixtureBuilder.CanBuildFrom)
                    .Select(TestFixtureBuilder.BuildFrom)
                    .ToList();

            builder.Add(fixtures);
            builder.RootSuite.Run(new ConsoleListener(), TestFilter.Empty);
        }
예제 #5
0
파일: PvcUtil.cs 프로젝트: modulexcite/pvc
        public static string StreamToTempFile(PvcStream stream)
        {
            // be sure to start from beginning
            stream.Position = 0;

            var tmpFileName = Path.GetTempFileName();
            File.WriteAllText(tmpFileName, new StreamReader(stream).ReadToEnd());

            return tmpFileName;
        }
 private PvcStream CompressStream(PvcStream inputStream)
 {
     string html = new StreamReader(inputStream).ReadToEnd();
     var compressed = compressor.compress(html);
     Console.WriteLine(string.Format("Minified {0} from {1} to {2} bytes", inputStream.StreamName, html.Length, compressed.Length));
     return PvcUtil.StringToStream(compressed, inputStream.StreamName);
 }