コード例 #1
0
        public void CanUpdateValidValues()
        {
            var pd = new CrcParameterDefinition();

            pd.Name = "TestParam";
            pd.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label1", Value = "Value1"
            });
            pd.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label2", Value = "Value2"
            });

            var newVV = new List <rws.ValidValue>();

            newVV.Add(new rws.ValidValue()
            {
                Label = "Label3", Value = "Value3"
            });

            var r = new CrcParameterRefresher();

            r.UpdateValidValues(pd, newVV.ToArray());

            Assert.AreEqual(1, pd.ValidValues.Count());
            var checkVV = pd.ValidValues[0];

            Assert.AreEqual("Label3", checkVV.Label);
            Assert.AreEqual("Value3", checkVV.Value);
        }
コード例 #2
0
        public void RefreshParameter_CanHandleNulls()
        {
            var pd = new CrcParameterDefinition();

            pd.Name            = "TestParam";
            pd.ParameterChoice = new CrcParameterChoice(pd.Name);
            pd.ParameterChoice.Values.Add("Value1");
            pd.ParameterChoice.Values.Add("Value2");
            pd.ParameterChoice.Values.Add("Value3");

            var latestParam = new rws.ReportParameter();

            latestParam.Name          = "TestParam";
            latestParam.ValidValues   = null;
            latestParam.DefaultValues = null;


            var r = new CrcParameterRefresher();

            r.RefreshParameter(pd, latestParam);

            Assert.IsNotNull(pd);
            Assert.AreEqual("TestParam", pd.Name);
            Assert.AreEqual(0, pd.ParameterChoice.Values.Count());
        }
コード例 #3
0
        public void IsChoiceValid_CanHandleEmptyChoice()
        {
            var pd = new CrcParameterDefinition();

            pd.Name = "TestParam";
            pd.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label1", Value = "Value1"
            });
            pd.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label2", Value = "Value2"
            });
            pd.ValidValues.Add(new CrcValidValue()
            {
                Label = "Label3", Value = "Value3"
            });

            pd.ParameterChoice = new CrcParameterChoice(pd.Name);

            var  r     = new CrcParameterRefresher();
            bool valid = r.IsChoiceValid(pd);

            Assert.IsTrue(valid);
        }
コード例 #4
0
        public void CanUpdateDefaultValues()
        {
            var pd = new CrcParameterDefinition();

            pd.Name            = "TestParam";
            pd.ParameterChoice = new CrcParameterChoice(pd.Name);
            pd.ParameterChoice.Values.Add("Value1");
            pd.ParameterChoice.Values.Add("Value2");
            pd.ParameterChoice.Values.Add("Value3");

            var newDV = new List <string>();

            newDV.Add("Value4");
            newDV.Add("Value5");

            var r = new CrcParameterRefresher();

            r.UpdateDefaultValues(pd, newDV.ToArray());

            Assert.AreEqual(2, pd.ParameterChoice.Values.Count());
            var check4 = pd.ParameterChoice.Values.FirstOrDefault(d => d == "Value4");

            Assert.IsNotNull(check4);
            var check5 = pd.ParameterChoice.Values.FirstOrDefault(d => d == "Value5");

            Assert.IsNotNull(check5);
        }
コード例 #5
0
        public void CanUpdateDefaultValues()
        {
            var pd = new CrcParameterDefinition();
            pd.Name = "TestParam";
            pd.ParameterChoice = new CrcParameterChoice(pd.Name);
            pd.ParameterChoice.Values.Add("Value1");
            pd.ParameterChoice.Values.Add("Value2");
            pd.ParameterChoice.Values.Add("Value3");

            var newDV = new List<string>();
            newDV.Add("Value4");
            newDV.Add("Value5");

            var r = new CrcParameterRefresher();
            r.UpdateDefaultValues(pd, newDV.ToArray());

            Assert.AreEqual(2, pd.ParameterChoice.Values.Count());
            var check4 = pd.ParameterChoice.Values.FirstOrDefault(d => d == "Value4");
            Assert.IsNotNull(check4);
            var check5 = pd.ParameterChoice.Values.FirstOrDefault(d => d == "Value5");
            Assert.IsNotNull(check5);
        }
コード例 #6
0
        public void RefreshParameter_CanHandleNulls()
        {
            var pd = new CrcParameterDefinition();
            pd.Name = "TestParam";
            pd.ParameterChoice = new CrcParameterChoice(pd.Name);
            pd.ParameterChoice.Values.Add("Value1");
            pd.ParameterChoice.Values.Add("Value2");
            pd.ParameterChoice.Values.Add("Value3");

            var latestParam = new rws.ReportParameter();
            latestParam.Name = "TestParam";
            latestParam.ValidValues = null;
            latestParam.DefaultValues = null;

            var r = new CrcParameterRefresher();
            r.RefreshParameter(pd, latestParam);

            Assert.IsNotNull(pd);
            Assert.AreEqual("TestParam", pd.Name);
            Assert.AreEqual(0, pd.ParameterChoice.Values.Count());
        }
コード例 #7
0
        public void IsChoiceValid_CanHandleMissingChoice()
        {
            var pd = new CrcParameterDefinition();
            pd.Name = "TestParam";
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label1", Value = "Value1" });
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label2", Value = "Value2" });
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label3", Value = "Value3" });

            var r = new CrcParameterRefresher();
            bool valid = r.IsChoiceValid(pd);

            Assert.IsTrue(valid);
        }
コード例 #8
0
        public void IsChoiceValid_CanDetectInValid()
        {
            var pd = new CrcParameterDefinition();
            pd.Name = "TestParam";
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label1", Value = "Value1" });
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label2", Value = "Value2" });
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label3", Value = "Value3" });

            pd.ParameterChoice = new CrcParameterChoice(pd.Name);
            pd.ParameterChoice.Values.Add("Value1");
            pd.ParameterChoice.Values.Add("Value5");

            var r = new CrcParameterRefresher();
            bool valid = r.IsChoiceValid(pd);

            Assert.IsFalse(valid);
        }
コード例 #9
0
        public void CanUpdateValidValues()
        {
            var pd = new CrcParameterDefinition();
            pd.Name = "TestParam";
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label1", Value = "Value1" });
            pd.ValidValues.Add(new CrcValidValue() { Label = "Label2", Value = "Value2" });

            var newVV = new List<rws.ValidValue>();
            newVV.Add(new rws.ValidValue(){ Label = "Label3", Value = "Value3"});

            var r = new CrcParameterRefresher();
            r.UpdateValidValues(pd, newVV.ToArray());

            Assert.AreEqual(1, pd.ValidValues.Count());
            var checkVV = pd.ValidValues[0];
            Assert.AreEqual("Label3", checkVV.Label);
            Assert.AreEqual("Value3", checkVV.Value);
        }
コード例 #10
0
        /// <summary>
        /// Applies the specified choices to the already-existing report definition
        /// and updates the dependant parameters
        /// </summary>
        public void RefreshDependantParameters(CrcReportDefinition repDefn, CrcParameterChoiceCollection newChoices)
        {
            var mapResult = repDefn.MapParameterChoices(newChoices);
            if (!mapResult.MappingValid)
            {
                // todo - friendlier message back to ui
                throw new ApplicationException(string.Format("invalid params - could not map supplied values to definitions for report {0}. complaints: {1}",
                    repDefn.DisplayName, string.Join(", ", mapResult.Complaints.ToArray())));
            }
            var conv = new CrcParameterConverter();
            List<ParameterValue> valueList = conv.GetParametersValuesForSsrsWebService(repDefn);
            // get new params from web service
            ReportingService2005Soap rService = m_ssrsSoapClientFactory.MakeSsrsSoapClient();
            logger.DebugFormat("RefreshDependantParameters: rep {0} calling WS to get new validvalid. Passing {1} values", repDefn.DisplayName, valueList.Count());

            var grpRequest = new GetReportParametersRequest(repDefn.ReportPath, null, true, valueList.ToArray(), null);
            var grpResponse = rService.GetReportParameters(grpRequest);

            // work out which params to refresh
            List<string> paramsToRefresh = new List<string>();
            foreach (string updatedParam in newChoices.ParameterChoiceList.Select(p => p.Name))
            {
                var paramDefn = repDefn.ParameterDefinitions.First(p => p.Name == updatedParam);
                paramsToRefresh = paramsToRefresh.Union(paramDefn.DependantParameterNames).ToList();
            }
            logger.DebugFormat("RefreshDependantParameters: rep {0} based on choices, have {1} parameters that need refreshing", repDefn.DisplayName, paramsToRefresh.Count());

            var refresher = new CrcParameterRefresher();
            foreach (string paramLoop in paramsToRefresh)
            {
                var paramDefn = repDefn.ParameterDefinitions.First(p => p.Name == paramLoop);
                var latestParamDetails = grpResponse.Parameters.FirstOrDefault(p => p.Name == paramLoop);
                if (latestParamDetails == null)
                    throw new ApplicationException(String.Format("Was expecting web service to return new details for parameter {0} but none found",
                        paramLoop));
                refresher.RefreshParameter(paramDefn, latestParamDetails);
            }
        }