コード例 #1
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());
        }
コード例 #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());
        }
コード例 #3
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"));
        }
コード例 #4
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"));
        }