Exemplo n.º 1
0
        public static FileInfo GetHtmlFormattedReport(string sessionId, bool condensed)
        {
            IDiskCacheGroup group     = GetReportCacheGroup(sessionId);
            string          directory = condensed ? "Condensed" : "Full";

            FileInfo htmlReportFile = group.GetFileInfo(Path.Combine(directory, HtmlReportFileName));

            if (!htmlReportFile.Exists)
            {
                Report report = LoadSerializedReport(sessionId);
                if (report == null)
                {
                    return(null);
                }

                group.CreateSubdirectory(directory);
                IReportManager            reportManager   = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>();
                FileSystemReportContainer reportContainer = new FileSystemReportContainer(htmlReportFile.DirectoryName, ReportBaseName);
                IReportWriter             reportWriter    = reportManager.CreateReportWriter(report, reportContainer);
                var reportFormatterOptions = new ReportFormatterOptions();
                reportManager.Format(reportWriter, condensed ? "Html-Condensed" : "Html", reportFormatterOptions, NullProgressMonitor.CreateInstance());
            }

            return(htmlReportFile);
        }
Exemplo n.º 2
0
 public ReportFilePool(IDiskCacheGroup cacheGroup, int numberOfFiles)
 {
     for (var i = 0; i < numberOfFiles; i++)
     {
         var uniqueFilename = string.Format("{0}.{1}.html", ReportName, Hash64.CreateUniqueHash());
         files.Add(cacheGroup.GetFileInfo(uniqueFilename));
     }
 }
Exemplo n.º 3
0
        public static void SaveSerializedReport(string sessionId, Report report)
        {
            IDiskCacheGroup group = GetReportCacheGroup(sessionId);

            group.Delete();

            BinaryFormatter formatter = CreateBinaryFormatter();

            using (Stream stream = group.OpenFile(SerializedReportFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Delete))
                formatter.Serialize(stream, report);
        }
        public HtmlTestStepRunFormatter()
        {
            var runtime = RuntimeAccessor.Instance;
            var resourcesPath = runtime.ResourceLocator.ResolveResourcePath(new Uri("plugin://Gallio.Reports/Resources/"));
            resourcesUrl = new Uri(resourcesPath);
            cssUrl = new Uri(resourcesUrl, "css");
            imgUrl = new Uri(resourcesUrl, "img");
            jsDir = Path.Combine(resourcesPath, "js");

            cache = new TemporaryDiskCache("Gallio.UI");
            cacheGroup = cache.Groups[Guid.NewGuid().ToString()];
            reportFilePool = new ReportFilePool(cacheGroup, 5);
            attachmentPaths = new HashSet<string>();
        }
Exemplo n.º 5
0
        public HtmlTestStepRunFormatter()
        {
            var runtime       = RuntimeAccessor.Instance;
            var resourcesPath = runtime.ResourceLocator.ResolveResourcePath(new Uri("plugin://Gallio.Reports/Resources/"));

            resourcesUrl = new Uri(resourcesPath);
            cssUrl       = new Uri(resourcesUrl, "css");
            imgUrl       = new Uri(resourcesUrl, "img");
            jsDir        = Path.Combine(resourcesPath, "js");

            cache           = new TemporaryDiskCache("Gallio.UI");
            cacheGroup      = cache.Groups[Guid.NewGuid().ToString()];
            reportFilePool  = new ReportFilePool(cacheGroup, 5);
            attachmentPaths = new HashSet <string>();
        }
Exemplo n.º 6
0
        public static Report LoadSerializedReport(string sessionId)
        {
            try
            {
                if (HasSerializedReport(sessionId))
                {
                    IDiskCacheGroup group     = GetReportCacheGroup(sessionId);
                    BinaryFormatter formatter = CreateBinaryFormatter();
                    using (Stream stream = group.OpenFile(SerializedReportFileName, FileMode.Open, FileAccess.Read, FileShare.Delete))
                        return((Report)formatter.Deserialize(stream));
                }
            }
            catch (DiskCacheException)
            {
            }

            return(null);
        }
Exemplo n.º 7
0
        public static bool HasSerializedReport(string sessionId)
        {
            IDiskCacheGroup group = GetReportCacheGroup(sessionId);

            return(group.Exists && group.GetFileInfo(SerializedReportFileName).Exists);
        }
Exemplo n.º 8
0
        public static void ClearSerializedReport(string sessionId)
        {
            IDiskCacheGroup group = GetReportCacheGroup(sessionId);

            group.Delete();
        }
 public ReportFilePool(IDiskCacheGroup cacheGroup, int numberOfFiles)
 {
     for (var i = 0; i < numberOfFiles; i++)
     {
         var uniqueFilename = string.Format("{0}.{1}.html", ReportName, Hash64.CreateUniqueHash());
         files.Add(cacheGroup.GetFileInfo(uniqueFilename));
     }
 }