示例#1
0
文件: Program.cs 项目: iamguid/tdd
        static void DrawLayoutResult(ICloudLayouter layouter, Size[] rects, string layoutName)
        {
            foreach (var el in rects)
            {
                layouter.PutNextRectangle(el);
            }

            var resultImagePath = Path.Combine(Directory.GetCurrentDirectory(), $"{layoutName}.png");

            CloudLayoutVisualizer.SaveAsPngImage(layouter.GetLayout(), resultImagePath);
            System.Console.WriteLine($"Layout {layoutName} saved to {resultImagePath}");
        }
示例#2
0
        private void SaveLayoutToImageIfCurrentTestFailed()
        {
            var layout = _layouter.GetLayout();

            if (!layout.Any())
            {
                return;
            }

            var testResult = TestContext.CurrentContext.Result.Outcome;

            if (Equals(testResult, ResultState.Failure) || Equals(testResult == ResultState.Error))
            {
                var fileName = $"{TestContext.CurrentContext.Test.Name}_failed.png";
                var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, fileName);
                CloudLayoutVisualizer.SaveAsPngImage(layout, filePath);
                Console.WriteLine($"Tag cloud visualization saved to file {filePath}");
            }
        }