Ejemplo n.º 1
0
        public void Should_not_collide_with_two_controllers()
        {
            var view = new XtraReport {
                DataSource = new[] { new object(), new object() }
            };

            var counterA = 0;
            var counterB = 0;

            var actionA = ReportRuntimeAction <XRControl> .WithNoPredicate(c => counterA++);

            var actionB = ReportRuntimeAction <XRControl> .WithNoPredicate(c => counterB++);

            var facadeA = new XRRuntimeActionFacade(actionA);
            var facadeB = new XRRuntimeActionFacade(actionB);

            var controllerA = new XRReportController(view, facadeA);
            var controllerB = new XRReportController(view, facadeB);

            controllerA.Print(r => r.ExportToMemory());
            controllerB.Print(r => r.ExportToMemory());

            counterA.Should().Be(1);
            counterB.Should().Be(1);
        }
Ejemplo n.º 2
0
        public void Should_pass_root_hashcode()
        {
            var view = new XtraReport {
                DataSource = new[] { new object(), new object() }
            };

            var detailBand = new DetailBand();
            var container  = new XRSubreport();
            var subReport  = new MyReportBase();

            container.ReportSource = subReport;
            detailBand.Controls.Add(container);
            view.Bands.Add(detailBand);

            IReportController   myController = new XRReportController(view);
            Action <XtraReport> printAction  = r => r.ExportToMemory();
            var newView = myController.Print(printAction);

            var subReportsHashcode =
                ((MyReportBase)((XRSubreport)newView.Bands[BandKind.Detail].Controls[0]).ReportSource).RootHashCode;

            newView.RootHashCode.Should().NotBe(0);

            subReportsHashcode.Should().Be(newView.RootHashCode);
        }
        public void WhenTheReportRuns()
        {
            _filename2 = Helpers.GetNewTempFile() + ".html";
            var controller = new XRReportController(_report, new XRRuntimeActionFacade(_action));

            controller.Print(p => p.ExportToHtml(_filename2));
        }
Ejemplo n.º 4
0
        public void Should_Dispose_visitors()
        {
            var view = new XtraReport {DataSource = new[] {new object(), new object()}};
            var controllerA = new XRReportController(view);
            var view2 = controllerA.Print(r => r.ExportToMemory());

            GlobalXRSubscriber.Singleton.Visitors.Values.Count(wr => wr.IsAlive && ((XRRuntimeVisitor)wr.Target).ReportHashcode == view2.RootHashCode).Should().Be(1);
            GC.Collect();
            GlobalXRSubscriber.Singleton.Visitors.Values.Count(wr => wr.IsAlive && ((XRRuntimeVisitor)wr.Target).ReportHashcode == view2.RootHashCode).Should().Be(0);
        }
        public void applies_to_entire_report()
        {
            var color  = Color.Green;
            var action = new ReportRuntimeAction <XtraReport>(r => true, r => r.BackColor = color);

            var report    = new ReportFactory().GetNewReport();
            var newReport = new XRReportController(report, new XRRuntimeActionFacade(action)).Print(r => r.ExportToMemory());

            Assert.AreEqual(color, newReport.BackColor);
        }
        public void applies_to_entire_report()
        {
            var color = Color.Green;
            var action = new ReportRuntimeAction<XtraReport>(r => true, r => r.BackColor = color);

            var report = new ReportFactory().GetNewReport();
            var newReport = new XRReportController(report, new XRRuntimeActionFacade(action)).Print(r => r.ExportToMemory());

            Assert.AreEqual(color, newReport.BackColor);
        }
Ejemplo n.º 7
0
        public void Should_Dispose_visitors() // no memory leaks here!
        {
            var view = new XtraReport {
                DataSource = new[] { new object(), new object() }
            };
            var controllerA = new XRReportController(view);
            var view2       = controllerA.Print(r => r.ExportToMemory());

            GlobalXRSubscriber.Singleton.Visitors.Values.Count(wr => wr.IsAlive && ((XRRuntimeVisitor)wr.Target).ReportHashcode == view2.RootHashCode).Should().Be(1);
            GC.Collect();
            GlobalXRSubscriber.Singleton.Visitors.Values.Count(wr => wr.IsAlive && ((XRRuntimeVisitor)wr.Target).ReportHashcode == view2.RootHashCode).Should().Be(0);
        }
        public void Should_convert_subreport_to_myReportBase()
        {
            var report             = new XtraReport();
            var detailBand         = new DetailBand();
            var subReportContainer = new XRSubreport {
                ReportSource = new XtraReport()
            };

            report.Bands.Add(detailBand);
            detailBand.Controls.Add(subReportContainer);


            var controller = new XRReportController(report);
            var newReport  = controller.Print(p => p.ExportToMemory());

            var newContainer = (XRSubreport)newReport.Bands[0].Controls[0];

            newContainer.ReportSource.GetType().Should().Be(typeof(MyReportBase));
        }
Ejemplo n.º 9
0
        public void Should_not_collide_with_two_controllers()
        {
            var view = new XtraReport {DataSource = new[] {new object(), new object()}};

            var counterA = 0;
            var counterB = 0;

            var actionA = ReportRuntimeAction<XRControl>.WithNoPredicate(c => counterA++);
            var actionB = ReportRuntimeAction<XRControl>.WithNoPredicate(c => counterB++);
            var facadeA = new XRRuntimeActionFacade(actionA);
            var facadeB = new XRRuntimeActionFacade(actionB);

            var controllerA = new XRReportController(view, facadeA);
            var controllerB = new XRReportController(view, facadeB);

            controllerA.Print(r => r.ExportToMemory());
            controllerB.Print(r => r.ExportToMemory());

            counterA.Should().Be(1);
            counterB.Should().Be(1);
        }
Ejemplo n.º 10
0
        public void Should_pass_root_hashcode()
        {
            var view = new XtraReport {DataSource = new[] {new object(), new object()}};

            var detailBand = new DetailBand();
            var container = new XRSubreport();
            var subReport = new MyReportBase();

            container.ReportSource = subReport;
            detailBand.Controls.Add(container);
            view.Bands.Add(detailBand);

            IReportController myController = new XRReportController(view);
            Action<XtraReport> printAction = r => r.ExportToMemory();
            var newView = myController.Print(printAction);

            var subReportsHashcode =
                ((MyReportBase) ((XRSubreport) newView.Bands[BandKind.Detail].Controls[0]).ReportSource).RootHashCode;

            newView.RootHashCode.Should().NotBe(0);

            subReportsHashcode.Should().Be(newView.RootHashCode);
        }
        public void GivenTheXtrasubreportEngineIsInitialized()
        {
            var facade = new XRRuntimeActionFacade(_action);

            _controller = new XRReportController(_report, facade);
        }
 public void WhenTheReportRuns()
 {
     _filename2 = Helpers.GetNewTempFile() + ".html";
     var controller = new XRReportController(_report, new XRRuntimeActionFacade(_action));
     controller.Print(p => p.ExportToHtml(_filename2));
 }
        public void Should_handle_detail_reports_with_subreport()
        {
            var textvalues = new List<Tuple<int,string>>();
            var report = new XtraReportWithSubReportInDetailReport();
            report.DataSource = new List<Person2>
                                    {
                                        new Person2
                                            {
                                                Name = "Douglas Sam",
                                                Age = 17,
                                                Dogs = new List<Dog> {new Dog {Name = "Rex"}, new Dog {Name = "Rudy"}}
                                            },
                                        new Person2
                                            {
                                                Name = "Fred Thomas",
                                                Age = 35,
                                                Dogs =
                                                    new List<Dog> {new Dog {Name = "Sally"}, new Dog {Name = "Stubert"}}
                                            },
                                        new Person2
                                            {
                                                Name = "Alex Matthew",
                                                Age = 100,
                                                Dogs =
                                                    new List<Dog>
                                                        {new Dog {Name = "Nibbles"}, new Dog {Name = "Norbert"}}
                                            }

                                    };
            int counter = 0;
            var action = ReportRuntimeAction<XRLabel>.WithNoPredicate(l =>
                                                              {
                                                                  counter++;
                                                                  textvalues.Add(new Tuple<int, string>(l.Report.GetHashCode(), l.Text));
                                                              });
            var facade = new XRRuntimeActionFacade(action);

            var c = new XRReportController(report, facade);
            var newReport = c.Print(a=> a.ExportToMemory());
            //Not safe for batch test runs GlobalXRSubscriber.Singleton.Visitors.Count.Should().Be(2);
            counter.Should().Be(6);
        }
        public void Should_convert_subreport_to_myReportBase()
        {
            var report = new XtraReport();
            var detailBand = new DetailBand();
            var subReportContainer = new XRSubreport {ReportSource = new XtraReport()};
            report.Bands.Add(detailBand);
            detailBand.Controls.Add(subReportContainer);

            var controller = new XRReportController(report);
            var newReport = controller.Print(p=> p.ExportToMemory());

            var newContainer = (XRSubreport) newReport.Bands[0].Controls[0];
            newContainer.ReportSource.GetType().Should().Be(typeof (MyReportBase));
        }
        public void Should_handle_detail_reports()
        {
            var textvalues = new List <Tuple <int, string> >();
            var report     = new XtraReportWithLabelInDetailReport();

            report.DataSource = new List <Person2>
            {
                new Person2
                {
                    Name = "Douglas Sam",
                    Age  = 17,
                    Dogs = new List <Dog> {
                        new Dog {
                            Name = "Rex"
                        }, new Dog {
                            Name = "Rudy"
                        }
                    }
                },
                new Person2
                {
                    Name = "Fred Thomas",
                    Age  = 35,
                    Dogs =
                        new List <Dog> {
                        new Dog {
                            Name = "Sally"
                        }, new Dog {
                            Name = "Stubert"
                        }
                    }
                },
                new Person2
                {
                    Name = "Alex Matthew",
                    Age  = 100,
                    Dogs =
                        new List <Dog>
                    {
                        new Dog {
                            Name = "Nibbles"
                        }, new Dog {
                            Name = "Norbert"
                        }
                    }
                }
            };
            int counter = 0;
            var action  = ReportRuntimeAction <XRLabel> .WithNoPredicate(l =>
            {
                counter++;
                textvalues.Add(new Tuple <int, string>(l.Report.GetHashCode(), l.Text));
            });

            var facade = new XRRuntimeActionFacade(action);

            var c         = new XRReportController(report, facade);
            var newReport = c.Print(a => a.ExportToMemory());

            counter.Should().Be(6);
        }
Ejemplo n.º 16
0
        public static void RunReport(XtraReport report, params IReportRuntimeAction[] action)
        {
            var controller = new XRReportController(report, new XRRuntimeActionFacade(action));

            controller.Print(r => r.ExportToHtml(new MemoryStream(), new HtmlExportOptions()));
        }
 public void GivenTheXtrasubreportEngineIsInitialized()
 {
     var facade = new XRRuntimeActionFacade(_action);
     _controller = new XRReportController(_report, facade);
 }