コード例 #1
0
        public void TableHeaderTextBoxRender2010_ShouldRenderTextBoxRdlFragment()
        {
            var ServiceLocatorMock = new Mock <ISimpleServiceLocator>();

            SimpleServiceLocator.SetServiceLocatorProvider(ServiceLocatorMock.Object);

            var reportingStyleLeftMock = new Mock <IReportingServicesStyle>();

            reportingStyleLeftMock.Setup(x => x.TextAlign).Returns("");

            ServiceLocatorMock.Setup(x => x.Get <IReportingServicesStyle>
                                         ("ReportingServicesStyle", It.IsAny <Dictionary <string, object> >())).Returns(reportingStyleLeftMock.Object);

            string             name    = "Field1";
            string             caption = "Caption1";
            TableHeaderTextBox target  = new TableHeaderTextBox(name, caption);
            //Create stringbuilder for the xmlwriter
            StringBuilder sb = new StringBuilder();

            using (XmlWriter xmlWriter = XmlWriter.Create(sb))
            {
                //method under test
                target.Render2010(xmlWriter);

                //flush the output and grab the xml chunk
                xmlWriter.Flush();
                string outputRdl = sb.ToString();

                //compare output with expected xml
                XmlAssert.AreEqual(outputRdl, "<TablixCell><CellContents><Textbox Name=\"HeaderField1\"><Paragraphs><Paragraph><TextRuns><TextRun><Value>Caption1</Value></TextRun></TextRuns></Paragraph></Paragraphs><CanGrow>true</CanGrow><Top>0in</Top><Left>0in</Left><Width>.5in</Width></Textbox></CellContents></TablixCell>");
            }
        }
コード例 #2
0
        public void TableHeaderTextBoxConstructor_ShouldSetTheNameAndCaptionProperties()
        {
            var ServiceLocatorMock = new Mock <ISimpleServiceLocator>();

            SimpleServiceLocator.SetServiceLocatorProvider(ServiceLocatorMock.Object);

            string             name           = "Table1";
            string             caption        = "Caption1";
            bool               isRightAligned = false;
            TableHeaderTextBox target         = new TableHeaderTextBox(name, caption, isRightAligned);

            Assert.AreEqual(target.Name, "Table1");
            Assert.AreEqual(target.Caption, "Caption1");
        }
コード例 #3
0
        public void TableHeaderTextBoxConstructor_ShouldSetTheAlignmentToRightIfPassed()
        {
            var ServiceLocatorMock = new Mock <ISimpleServiceLocator>();

            SimpleServiceLocator.SetServiceLocatorProvider(ServiceLocatorMock.Object);

            var reportingStyleMock = new Mock <IReportingServicesStyle>();

            reportingStyleMock.Setup(x => x.TextAlign).Returns("Right");

            ServiceLocatorMock.Setup(x => x.Get <IReportingServicesStyle>
                                         ("ReportingServicesStyleRight", It.IsAny <Dictionary <string, object> >())).Returns(reportingStyleMock.Object);

            string name           = "Table1";
            string caption        = "Caption1";
            bool   isRightAligned = true;

            TableHeaderTextBox target = new TableHeaderTextBox(name, caption, isRightAligned);

            ServiceLocatorMock.Verify(x => x.Get <IReportingServicesStyle>("ReportingServicesStyleRight", It.IsAny <Dictionary <string, object> >()), Times.Once());
            ServiceLocatorMock.Verify(x => x.Get <IReportingServicesStyle>("ReportingServicesStyle", It.IsAny <Dictionary <string, object> >()), Times.Never());
            Assert.AreEqual(target.TextboxStyle.TextAlign, "Right");
        }