Exemple #1
0
        private static bool MultivalueEquals(MultiValueParameter mv, string comparand)
        {
            foreach (string s in mv.Values)
            {
                if (string.Equals(s, comparand, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(false);
        }
 public void MultiValueParameterParsing()
 {
     using (TextReader reader = new StringReader("<param_list name=\"multiValue\"><value>value3</value>" +
                                                 "<value>value4</value></param_list>"))
     {
         MultiValueParameter parameter =
             (MultiValueParameter) new XmlSerializer(typeof(MultiValueParameter)).Deserialize(reader);
         Assert.Equal("multiValue", parameter.Name);
         Assert.Equal(new List <string> {
             "value3", "value4"
         }, parameter.Values);
     }
 }
        public void MultiValueParameterConversions()
        {
            Collection <string> values;
            MultiValueParameter parameter;

            values = new Collection <string> {
                "abc", "def"
            };
            parameter = new MultiValueParameter("some_name", values);

            Assert.Equal(values, parameter.ToStringCollection());

            values = new Collection <string> {
                "true", "0"
            };
            parameter = new MultiValueParameter("some_name", values);

            Assert.Equal(new Collection <bool> {
                true, false
            }, parameter.ToBooleanCollection());

            values = new Collection <string> {
                "52", "42"
            };
            parameter = new MultiValueParameter("some_name", values);

            Assert.Equal(new Collection <double> {
                (double)52, (double)42
            }, parameter.ToDoubleCollection());
            Assert.Equal(new Collection <float> {
                (float)52, (float)42
            }, parameter.ToSingleCollection());
            Assert.Equal(new Collection <int> {
                52, 42
            }, parameter.ToInt32Collection());
            Assert.Equal(new Collection <long> {
                52, 42
            }, parameter.ToInt64Collection());
        }