public async Task RendersRibbonPlotsCorrectly()
        {
            var fixture = this.CreateTestData(this.outputDirectory);

            var result = await RibbonPlot.Execute(new RibbonPlot.Arguments()
            {
                InputDirectories = new[] { fixture },
                OutputDirectory  = this.outputDirectory,
            });

            Assert.AreEqual(0, result);

            var plot1 = this.outputDirectory.CombineFile($"{this.outputDirectory.Name}__RibbonPlot_ACI-ENT-EVN.png");

            Assert.That.FileExists(plot1);
            var plot2 = this.outputDirectory.CombineFile($"{this.outputDirectory.Name}__RibbonPlot_BGN-PMN-OSC.png");

            Assert.That.FileExists(plot2);
            var plot3 = this.outputDirectory.CombineFile($"{this.outputDirectory.Name}__RibbonPlot_ENT-CVR-OSC.png");

            Assert.That.FileExists(plot3);

            const int Left   = 223;
            const int Height = ((32 + 2) * 12) + 2;

            // whole image that goes all through the data
            var image1 = Image.Load <Rgb24>(File.ReadAllBytes(plot1.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image1);

            var expectedRibbons1 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(Horizontal.Left, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(6)
                                   .Fill(1440, 32, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Fill(1440, 32, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(5)
                                   .Fill(1440, 32, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Finish(this.outputDirectory.CombineFile("expectedRibbons1.png"));

            Assert.That.ImageContainsExpected(expectedRibbons1, new Point(Left, 0), image1);

            // 6 days image, second color map
            var image2 = Image.Load <Rgb24>(File.ReadAllBytes(plot2.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image2);

            var expectedRibbons2 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(Horizontal.Left, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(6)
                                   .Fill(1440, 32, Color.Blue)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Repeat(6)
                                   .Fill(1440, 32, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Finish();

            Assert.That.ImageContainsExpected(expectedRibbons2, new Point(Left, 0), image2);

            // skip 6 days, then 5 days of image, second color map
            var image3 = Image.Load <Rgb24>(File.ReadAllBytes(plot3.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image3);

            var expectedRibbons3 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(Horizontal.Left, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(7)
                                   .Fill(1440, 32, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Repeat(5)
                                   .Fill(1440, 32, Color.Green)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Finish(this.outputDirectory.CombineFile("expectedRibbons3.png"));

            Assert.That.ImageContainsExpected(expectedRibbons3, new Point(Left, 0), image3);
        }
Example #2
0
        public async Task RendersRibbonPlotsWithDifferentMidnightCorrectly()
        {
            var fixture = this.CreateTestData(this.TestOutputDirectory);

            var result = await RibbonPlot.Execute(new RibbonPlot.Arguments()
            {
                InputDirectories = new[] { fixture },
                OutputDirectory  = this.TestOutputDirectory,
                Midnight         = TimeSpan.FromHours(12),
            });

            Assert.AreEqual(0, result);

            var plot1 = this.TestOutputDirectory.CombineFile($"{this.TestOutputDirectory.Name}__RibbonPlot_ACI-ENT-EVN_Midnight=1200.png");

            Assert.That.FileExists(plot1);
            var plot2 = this.TestOutputDirectory.CombineFile($"{this.TestOutputDirectory.Name}__RibbonPlot_BGN-PMN-OSC_Midnight=1200.png");

            Assert.That.FileExists(plot2);
            var plot3 = this.TestOutputDirectory.CombineFile($"{this.TestOutputDirectory.Name}__RibbonPlot_ENT-CVR-OSC_Midnight=1200.png");

            Assert.That.FileExists(plot3);

            // label width + padding left + padding right
            const int Left   = 200 + 10 + 10;
            const int Height = ((32 + 2) * (12 + 1)) + 2;

            // whole image that goes all through the data (but it is two rows longer because of midnight config)
            var image1 = Image.Load <Rgb24>(File.ReadAllBytes(plot1.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image1);

            var expectedRibbons1 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(720, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .FillHorizontalSplit(1440, 32, Color.Gray, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(5)
                                   .Fill(1440, 32, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .FillHorizontalSplit(1440, 32, Color.Red, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .FillHorizontalSplit(1440, 32, Color.Gray, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(4)
                                   .Fill(1440, 32, Color.Red)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .FillHorizontalSplit(1440, 32, Color.Red, Color.Gray)
                                   .Finish(this.TestOutputDirectory.CombineFile("expectedRibbons1.png"));

            Assert.That.ImageContainsExpected(expectedRibbons1, new Point(Left, 0), image1);

            // 6 days image, second color map (but it is two rows longer because of midnight config)
            var image2 = Image.Load <Rgb24>(File.ReadAllBytes(plot2.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image2);

            var expectedRibbons2 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(720, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .FillHorizontalSplit(1440, 32, Color.Gray, Color.Blue)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(5)
                                   .Fill(1440, 32, Color.Blue)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .FillHorizontalSplit(1440, 32, Color.Blue, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(6)
                                   .Fill(1440, 32, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .Finish();

            Assert.That.ImageContainsExpected(expectedRibbons2, new Point(Left, 0), image2);

            // skip 6 days, then 5 days of image, second color map (but it is two rows longer because of midnight config)
            var image3 = Image.Load <Rgb24>(File.ReadAllBytes(plot3.FullName));

            Assert.That.ImageIsSize(1440 + Left + 10, Height, image3);

            var expectedRibbons3 = new TestImage(1440 + 10, Height, Color.White)
                                   .Move(720, 2)
                                   .Fill(1, Height - 2, Color.Red)
                                   .Move(Edge.TopLeft)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(7)
                                   .Fill(1440, 32, Color.Gray)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .FillHorizontalSplit(1440, 32, Color.Gray, Color.Green)
                                   .Move(Horizontal.Left, 2)
                                   .Repeat(4)
                                   .Fill(1440, 32, Color.Green)
                                   .Move(Horizontal.Left, 2)
                                   .EndRepeat()
                                   .FillHorizontalSplit(1440, 32, Color.Green, Color.Gray)
                                   .Finish();

            Assert.That.ImageContainsExpected(expectedRibbons3, new Point(Left, 0), image3);
        }