Ejemplo n.º 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());
        }
Ejemplo n.º 2
0
        public void CanGetReportDefn()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var serviceMock = mf.MakeMockReportingService2005Soap(
                                    mf.MakeSimpleTestParameters());
            mf.SetListChildrenExpectation(serviceMock, @"/", new CatalogItem[] { new CatalogItem() {
                Path = "TestReport",
                Name = "TestReportName",
                Description = "TestReportDescription",
                Type = ItemTypeEnum.Report}});
            var soapClientFactory = mf.MakeMockSoapClientFactory(serviceMock);

            var cacheMock = MockRepository.GenerateMock<CrcCacheManager>();
            // return empty cache when asked
            cacheMock.Expect(m => m.AllReportsCacheByUsername).Return(new TimedCache<CatalogItem[]>("test1",10,10));
            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();

            // make main service obj
            var ccs = new CrissCrossServices(soapClientFactory, cacheMock, configMock, null);

            var repDefn = ccs.GetReportDefn("TestReport", "TestUser");

            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());
        }
Ejemplo n.º 3
0
        public void CanMakeReportAndIgnoreSSRSDependencies()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDependantTestParameters();

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

            configMock.Expect(m => m.IgnoreSsrsParameterDependencies).Return(true);

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


            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(3, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");

            Assert.IsNotNull(p1check);
            Assert.AreEqual(0, p1check.DependantParameterNames.Count());

            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");

            Assert.IsNotNull(p2check);
            Assert.AreEqual(0, p2check.DependantParameterNames.Count());

            var p3check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamThree");

            Assert.IsNotNull(p3check);
            Assert.AreEqual(0, p3check.DependantParameterNames.Count());
        }
Ejemplo n.º 4
0
        public void CanMakeSimpleReportWithDefaultDate()
        {
            // test to catch default date formatting bug

            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDateTestParameters();

            // set a default date in the format that comes out of ssrs
            paramArray[0].DefaultValues = new string[] { "2/1/2010 12:00:00 AM" };

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

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


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

            Assert.IsNotNull(p1check);
            Assert.AreEqual("2010-02-01", p1check.ParameterChoice.SingleValue);
            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");

            Assert.IsNotNull(p2check);
            Assert.IsNull(p2check.ParameterChoice.SingleValue);
        }
Ejemplo n.º 5
0
        public void CanMakeReportWithExtraConfigSpecificEmptyEquivalents()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            var extraConfig = new CrcExtraConfiguration();
            var repConfig   = new CrcReportConfig();

            repConfig.Path            = "TestReport";
            repConfig.CrcParamConfigs = new List <CrcReportConfig.CrcParamConfig>();
            repConfig.CrcParamConfigs.Add(new CrcReportConfig.CrcParamConfig()
            {
                ParamName             = "ParamOne",
                EmptyEquivalentValues = new List <string>()
                {
                    "Value1"
                }
            });
            extraConfig.CrcReportConfigs.Add(repConfig);

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


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

            Assert.IsNotNull(p1check);
            Assert.AreEqual(1, p1check.EmptyEquivalentValues.Count());
            Assert.IsTrue(p1check.EmptyEquivalentValues.Contains("Value1"));
        }
Ejemplo n.º 6
0
        public void CanMakeSimpleReportWithNullDefaults()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            paramArray[0].DefaultValues = null;

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

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


            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            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());
        }
Ejemplo n.º 7
0
        public void CanMakeReportWithExtraConfigDependants()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDependantTestParameters();

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

            repConfig.Path            = "TestReport";
            repConfig.CrcParamConfigs = new List <CrcReportConfig.CrcParamConfig>();
            repConfig.CrcParamConfigs.Add(new CrcReportConfig.CrcParamConfig()
            {
                ParamName       = "ParamOne",
                DependantParams = new List <string>()
                {
                    "ParamThree"
                }
            });
            configMock.Expect(m => m.GetReportConfig(null)).IgnoreArguments().Return(repConfig);
            configMock.Expect(m => m.DefaultEmptyEquivalentValues).Return(new List <string>());

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


            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(3, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");

            Assert.IsNotNull(p1check);
            Assert.AreEqual(1, p1check.DependantParameterNames.Count());
            Assert.IsTrue(p1check.DependantParameterNames.Contains("ParamThree"));

            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");

            Assert.IsNotNull(p2check);
            Assert.AreEqual(0, p2check.DependantParameterNames.Count());

            var p3check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamThree");

            Assert.IsNotNull(p3check);
            Assert.AreEqual(0, p3check.DependantParameterNames.Count());
        }
Ejemplo n.º 8
0
        public void CanGetReportDefn()
        {
            var mf          = new TestDoubles.MockSsrsWebServiceFactory();
            var serviceMock = mf.MakeMockReportingService2010Soap(
                mf.MakeSimpleTestParameters());

            mf.SetListChildrenExpectation(serviceMock, @"/", new CatalogItem[] { new CatalogItem()
                                                                                 {
                                                                                     Path        = "TestReport",
                                                                                     Name        = "TestReportName",
                                                                                     Description = "TestReportDescription",
                                                                                     TypeName    = CrissCrossLib.Hierarchical.CrcReportFolderFactory.ReportServiceItemTypes.Report
                                                                                 } });
            var soapClientFactory = mf.MakeMockSoapClientFactory(serviceMock);


            var cacheMock = MockRepository.GenerateMock <CrcCacheManager>();

            // return empty cache when asked
            cacheMock.Expect(m => m.AllReportsCacheByUsername).Return(new TimedCache <CatalogItem[]>("test1", 10, 10));
            var configMock = MockRepository.GenerateMock <CrcExtraConfiguration>();

            // make main service obj
            var ccs = new CrissCrossServices(soapClientFactory, cacheMock, configMock, null);

            var repDefn = ccs.GetReportDefn("TestReport", "TestUser");

            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());
        }
Ejemplo n.º 9
0
        public void CanMakeReportWithHintFromExtraConfig()
        {
            var mf         = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

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

            repConfig.Path       = "TestReport";
            repConfig.ReportHint = "This is a report hint";
            configMock.Expect(m => m.GetReportConfig(null)).IgnoreArguments().Return(repConfig);

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


            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual("This is a report hint", repDefn.ReportHint);
        }
        public void CanMakeSimpleReportWithDefaultDate()
        {
            // test to catch default date formatting bug

            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDateTestParameters();
            // set a default date in the format that comes out of ssrs
            paramArray[0].DefaultValues = new string[] { "2/1/2010 12:00:00 AM"};

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

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual("2010-02-01", p1check.ParameterChoice.SingleValue);
            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");
            Assert.IsNotNull(p2check);
            Assert.IsNull(p2check.ParameterChoice.SingleValue);
        }
        public void CanMakeSimpleReportWithNullDefaults()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();
            paramArray[0].DefaultValues = null;

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

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            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());
        }
Ejemplo n.º 12
0
        public void CanRefreshDependantParameters_Simple()
        {
            // make report defn
            var repDefn = new CrcReportDefinition();
            repDefn.ReportPath = "Test/Report";
            var pd1 = new CrcParameterDefinition();
            pd1.Name = "ParamOne";
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label1", Value = "Value1" });
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label2", Value = "Value2" });
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label3", Value = "Value3" });
            pd1.DependantParameterNames.Add("ParamTwo");
            var pd2 = new CrcParameterDefinition();
            pd2.Name = "ParamTwo";
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel1_1", Value = "SubValue1_1" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel1_2", Value = "SubValue1_2" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel2_1", Value = "SubValue2_1" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel2_2", Value = "SubValue2_2" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel3_1", Value = "SubValue3_1" });
            repDefn.ParameterDefinitions.Add(pd1);
            repDefn.ParameterDefinitions.Add(pd2);

            // make choice collection
            var choiceCollection = new CrcParameterChoiceCollection();
            var paramChoice = new CrcParameterChoice("ParamOne");
            paramChoice.Values.Add("Value2");
            choiceCollection.ParameterChoiceList.Add( paramChoice);

            // make server side params to return
            ReportParameter p1 = new ReportParameter();
            p1.Name = "ParamOne";
            p1.ValidValues = new ValidValue[]{ new ValidValue(){Label = "Label1", Value = "Value1"},
                                    new ValidValue(){Label = "Label2", Value = "Value2"},
                                    new ValidValue(){Label = "Label3", Value = "Value3"}};
            p1.DefaultValues = new string[] { };
            ReportParameter p2 = new ReportParameter();
            p2.Name = "ParamTwo";
            p2.ValidValues = new ValidValue[]{ new ValidValue(){Label = "SubLabel2_1", Value = "SubValue2_1"},
                                    new ValidValue(){Label = "SubLabel2_2", Value = "SubValue2_2"}};
            p2.DefaultValues = new string[] { };
            ReportParameter[] paramArrayToReturn = new ReportParameter[] { p1, p2 };

            // make mocks for ccs
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var soapClientFactory = mf.MakeMockSoapClientFactory(
                        mf.MakeMockReportingService2005Soap("Value2", paramArrayToReturn));

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

            // make ccs
            var ccs = new CrissCrossServices(soapClientFactory, cacheMock, configMock, null);

            ccs.RefreshDependantParameters(repDefn, choiceCollection);

            Assert.AreEqual(2,repDefn.ParameterDefinitions.Count());
            var pd1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(pd1check);
            Assert.AreEqual("Value2", pd1check.ParameterChoice.SingleValue);
            var pd2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");
            Assert.IsNotNull(pd2check);
            Assert.AreEqual(2, pd2check.ValidValues.Count());
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault( vv => vv.Value == "SubValue2_1"));
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault( vv => vv.Value == "SubValue2_2"));
        }
        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 void CanMakeReportWithHintFromExtraConfig()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();
            var repConfig = new CrcReportConfig();
            repConfig.Path = "TestReport";
            repConfig.ReportHint = "This is a report hint";
            configMock.Expect(m => m.GetReportConfig(null)).IgnoreArguments().Return(repConfig);

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual("This is a report hint", repDefn.ReportHint);
        }
        public void CanMakeReportWithExtraConfigSpecificEmptyEquivalents()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeSimpleTestParameters();

            var extraConfig = new CrcExtraConfiguration();
            var repConfig = new CrcReportConfig();
            repConfig.Path = "TestReport";
            repConfig.CrcParamConfigs = new List<CrcReportConfig.CrcParamConfig>();
            repConfig.CrcParamConfigs.Add(new CrcReportConfig.CrcParamConfig()
            {
                ParamName = "ParamOne",
                EmptyEquivalentValues = new List<string>() { "Value1" }
            });
            extraConfig.CrcReportConfigs.Add(repConfig);

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual(1, p1check.EmptyEquivalentValues.Count());
            Assert.IsTrue(p1check.EmptyEquivalentValues.Contains("Value1"));
        }
        public void CanMakeReportWithExtraConfigDependants()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDependantTestParameters();

            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();
            var repConfig = new CrcReportConfig();
            repConfig.Path = "TestReport";
            repConfig.CrcParamConfigs = new List<CrcReportConfig.CrcParamConfig>();
            repConfig.CrcParamConfigs.Add(new CrcReportConfig.CrcParamConfig()
            {
                ParamName = "ParamOne",
                DependantParams = new List<string>() { "ParamThree" }
            });
            configMock.Expect(m => m.GetReportConfig(null)).IgnoreArguments().Return(repConfig);
            configMock.Expect(m => m.DefaultEmptyEquivalentValues).Return(new List<string>());

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(3, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual(1, p1check.DependantParameterNames.Count());
            Assert.IsTrue(p1check.DependantParameterNames.Contains("ParamThree"));

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

            var p3check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamThree");
            Assert.IsNotNull(p3check);
            Assert.AreEqual(0, p3check.DependantParameterNames.Count());
        }
        public void CanMakeReportAndInterpretSSRSDependencies()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var paramArray = mf.MakeDependantTestParameters();

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

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

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual(3, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual(2, p1check.DependantParameterNames.Count());
            Assert.IsTrue(p1check.DependantParameterNames.Contains("ParamTwo"));
            Assert.IsTrue(p1check.DependantParameterNames.Contains("ParamThree"));

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

            var p3check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamThree");
            Assert.IsNotNull(p3check);
            Assert.AreEqual(0, p3check.DependantParameterNames.Count());
        }
Ejemplo n.º 18
0
        public void CanRefreshDependantParameters_Simple()
        {
            // make report defn
            var repDefn = new CrcReportDefinition();

            repDefn.ReportPath = "Test/Report";
            var pd1 = new CrcParameterDefinition();

            pd1.Name = "ParamOne";
            pd1.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label1", Value = "Value1"
            });
            pd1.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label2", Value = "Value2"
            });
            pd1.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label3", Value = "Value3"
            });
            pd1.DependantParameterNames.Add("ParamTwo");
            var pd2 = new CrcParameterDefinition();

            pd2.Name = "ParamTwo";
            pd2.ValidValues.Add(new CrcValidValue()
            {
                Label = "SubLabel1_1", Value = "SubValue1_1"
            });
            pd2.ValidValues.Add(new CrcValidValue()
            {
                Label = "SubLabel1_2", Value = "SubValue1_2"
            });
            pd2.ValidValues.Add(new CrcValidValue()
            {
                Label = "SubLabel2_1", Value = "SubValue2_1"
            });
            pd2.ValidValues.Add(new CrcValidValue()
            {
                Label = "SubLabel2_2", Value = "SubValue2_2"
            });
            pd2.ValidValues.Add(new CrcValidValue()
            {
                Label = "SubLabel3_1", Value = "SubValue3_1"
            });
            repDefn.ParameterDefinitions.Add(pd1);
            repDefn.ParameterDefinitions.Add(pd2);


            // make choice collection
            var choiceCollection = new CrcParameterChoiceCollection();
            var paramChoice      = new CrcParameterChoice("ParamOne");

            paramChoice.Values.Add("Value2");
            choiceCollection.ParameterChoiceList.Add(paramChoice);

            // make server side params to return
            ItemParameter p1 = new ItemParameter();

            p1.Name        = "ParamOne";
            p1.ValidValues = new ValidValue[] { new ValidValue()
                                                {
                                                    Label = "Label1", Value = "Value1"
                                                },
                                                new ValidValue()
                                                {
                                                    Label = "Label2", Value = "Value2"
                                                },
                                                new ValidValue()
                                                {
                                                    Label = "Label3", Value = "Value3"
                                                } };
            p1.DefaultValues = new string[] { };
            ItemParameter p2 = new ItemParameter();

            p2.Name        = "ParamTwo";
            p2.ValidValues = new ValidValue[] { new ValidValue()
                                                {
                                                    Label = "SubLabel2_1", Value = "SubValue2_1"
                                                },
                                                new ValidValue()
                                                {
                                                    Label = "SubLabel2_2", Value = "SubValue2_2"
                                                } };
            p2.DefaultValues = new string[] { };
            ItemParameter[] paramArrayToReturn = new ItemParameter[] { p1, p2 };


            // make mocks for ccs
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var soapClientFactory = mf.MakeMockSoapClientFactory(
                mf.MakeMockReportingService2010Soap("Value2", paramArrayToReturn));

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

            // make ccs
            var ccs = new CrissCrossServices(soapClientFactory, cacheMock, configMock, null);


            ccs.RefreshDependantParameters(repDefn, choiceCollection);

            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var pd1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");

            Assert.IsNotNull(pd1check);
            Assert.AreEqual("Value2", pd1check.ParameterChoice.SingleValue);
            var pd2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");

            Assert.IsNotNull(pd2check);
            Assert.AreEqual(2, pd2check.ValidValues.Count());
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault(vv => vv.Value == "SubValue2_1"));
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault(vv => vv.Value == "SubValue2_2"));
        }