Пример #1
0
        public void CanMakeSimpleReportWithCatalogItem()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            var configMock = MockRepository.GenerateMock <CrcExtraConfiguration>();

            rws.CatalogItem catItem = new rws.CatalogItem()
            {
                Path        = "TestReport",
                Name        = "TestReportName",
                Description = "TestReportDescription"
            };

            // make main service obj
            var factory = new CrcReportDefinitionFactory();
            var repDefn = factory.Create("TestReport", catItem, paramArray, configMock);


            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual("TestReportName", repDefn.DisplayName);
            Assert.AreEqual("TestReportDescription", repDefn.Description);
            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");

            Assert.IsNotNull(p1check);
            Assert.AreEqual(2, p1check.ValidValues.Count());
            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");

            Assert.IsNotNull(p2check);
            Assert.AreEqual(2, p2check.ValidValues.Count());
        }
        public CrcReportDefinition Create(string reportPath, rws.CatalogItem reportCatItem, rws.ReportParameter[] wsReportParameters, CrcExtraConfiguration extraConfig)
        {
            var repDef = new CrcReportDefinition();

            repDef.ReportPath = reportPath;
            if (reportCatItem != null)
            {
                repDef.DisplayName = reportCatItem.Name;
                repDef.Description = reportCatItem.Description;
            }
            if (string.IsNullOrEmpty(repDef.DisplayName))
            {
                repDef.DisplayName = CrcReportDefinition.ReportNameFromPath(repDef.ReportPath);
            }

            CrcReportConfig repConfig = null;

            if (extraConfig != null)
            {
                repConfig = extraConfig.GetReportConfig(repDef.ReportPath);
            }

            if (repConfig != null)
            {
                repDef.ReportHint = repConfig.ReportHint;
            }

            AddParameterDefinitions(wsReportParameters, repDef, extraConfig, repConfig);

            bool readSsrsDependantParams = false;

            if (extraConfig == null || !extraConfig.IgnoreSsrsParameterDependencies)
            {
                readSsrsDependantParams = true;
            }
            if (repConfig != null && repConfig.DependantParamsSpecified)
            {
                readSsrsDependantParams = false;
            }
            if (readSsrsDependantParams)
            {
                AddSsrsDependentParams(wsReportParameters, repDef);
            }

            CrossReferenceDependantParameters(repDef);
            ApplyParameterDefaults(wsReportParameters, repDef);
            CheckRequiredFromUser(repDef);

            return(repDef);
        }
        public void CanMakeSimpleReportWithCatalogItem()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();

            rws.CatalogItem catItem = new rws.CatalogItem()
            {
                Path = "TestReport",
                Name = "TestReportName",
                Description = "TestReportDescription"
            };

            // make main service obj
            var factory = new CrcReportDefinitionFactory();
            var repDefn = factory.Create("TestReport", catItem, paramArray, configMock);

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual("TestReportName", repDefn.DisplayName);
            Assert.AreEqual("TestReportDescription", repDefn.Description);
            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual(2, p1check.ValidValues.Count());
            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");
            Assert.IsNotNull(p2check);
            Assert.AreEqual(2, p2check.ValidValues.Count());
        }