Example #1
0
        public void TestPieChartCompareWindow()
        {
            frmMain main = new frmMain();
            ChartSingleCompareOrig chart = main.LaunchChart(712, "splitdisplay", false);

            chart.Show();
            WinFormsApprovals.Verify(chart);
        }
Example #2
0
        public void TestBarChartSingle()
        {
            frmMain main = new frmMain();
            ChartSingleCompareOrig chart = main.LaunchChart(406, "rpfll", false);

            chart.Show();
            WinFormsApprovals.Verify(chart);
        }
Example #3
0
        public void TestPieChartWindow()
        {
            frmMain main = new frmMain();
            ChartSingleCompareOrig chart = main.LaunchChart(712, "rpfll", false);

            chart.Show();
            ApprovalTests.WinForms.Approvals.Approve(chart);
        }
Example #4
0
        public void TestBarChartCompareWindow()
        {
            frmMain main = new frmMain();
            //main.Show();
            ChartSingleCompareOrig chart = main.LaunchChart(150, "splitdisplay", false);

            chart.Show();
            ApprovalTests.WinForms.Approvals.Approve(chart);
        }
        public void TestBarChartWindow()
        {
            frmMain main = new frmMain();

            main.Show();
            ChartSingleCompareOrig chart = main.LaunchChart(150, "rpfll", false);

            chart.Show();

            byte[] generatedImgData;
            string approvedImgString;


            using (var generatedBitmap = new Bitmap(chart.Width, chart.Height))
            {
                chart.DrawToBitmap(generatedBitmap, new Rectangle(0, 0, chart.Width, chart.Height));
                using (var generatedBitmapStream = new MemoryStream())
                {
                    generatedBitmap.Save(generatedBitmapStream, ImageFormat.Png);
                    generatedImgData = generatedBitmapStream.GetBuffer();
                }
            }
            chart.Close();
            chart.Dispose();
            main.Close();
            main.Dispose();

            var assembly = Assembly.GetExecutingAssembly();

            using (
                var approvedStream =
                    assembly.GetManifestResourceStream("ChartSmart.Test.ChartSmartTest.TestBarChartWindow.approved.txt")
                )
            {
                using (var reader = new StreamReader(approvedStream))
                {
                    approvedImgString = reader.ReadToEnd();
                }
            }

            var generatedImgStringSb = new StringBuilder();

            foreach (var imgByte in generatedImgData)
            {
                generatedImgStringSb.Append(imgByte + ",");
            }
            var generatedImgString = generatedImgStringSb.ToString();

            //File.WriteAllText(@"C:\Projects\DesignPatternsAndSoftwareCraftmanship\DesignPrinciples\Refactoring\After\ChartSmart.Test\ChartSmartTest.TestBarChartWindow.txt", generatedImgString);

            Assert.IsTrue(approvedImgString == generatedImgString);
        }