示例#1
0
        public void TestPv2IntParamType(string paramName, string description, string Gr1, string formatString, string units, int min = int.MinValue, int max = int.MaxValue, int defaultValue = 0, Pv2ParamFlags flags = Pv2ParamFlags.NoFlags)
        {
            SpanTestHelper.SerializeDeserializeTestBegin(_output.WriteLine);
            var random = new Random();
            var type   = new Pv2IntParamType(paramName, description, Gr1, formatString, units, min, max, defaultValue, flags);

            ValidateParamType <int, Pv2IntParamType, Pv2IntParamValue>(type, _output.WriteLine);

            ValidateParamValue <int, Pv2IntParamType, Pv2IntParamValue>(type, type.Max, _output.WriteLine);
            ValidateParamValue <int, Pv2IntParamType, Pv2IntParamValue>(type, type.Min, _output.WriteLine);
            ValidateParamValue <int, Pv2IntParamType, Pv2IntParamValue>(type, type.DefaultValue, _output.WriteLine);

            for (var i = 0; i < 10; i++)
            {
                var realValue = random.Next(type.Min, type.Max);
                ValidateParamValue <int, Pv2IntParamType, Pv2IntParamValue>(type, realValue, _output.WriteLine);
            }
        }
示例#2
0
        public void ParamArgsError()
        {
            var param = new Pv2IntParamType("Param", string.Empty.PadLeft(Pv2ParamInterface.MaxDescriptionLength), "group1", string.Empty, string.Empty);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                var param = new Pv2IntParamType("Param", string.Empty.PadLeft(Pv2ParamInterface.MaxDescriptionLength + 1), "group1", string.Empty, string.Empty);
            });
            Assert.Throws <ArgumentException>(() =>
            {
                var param = new Pv2IntParamType("1Param", string.Empty.PadLeft(Pv2ParamInterface.MaxDescriptionLength), "group1", string.Empty, string.Empty);
            });

            Assert.Throws <ArgumentException>(() =>
            {
                var param = new Pv2IntParamType("Pa1ram", string.Empty.PadLeft(Pv2ParamInterface.MaxDescriptionLength), "1group1", string.Empty, string.Empty);
            });
            Assert.Throws <ArgumentException>(() =>
            {
                var param = new Pv2IntParamType("Pa1ram", string.Empty.PadLeft(Pv2ParamInterface.MaxDescriptionLength), "1group1", string.Empty, string.Empty, 20, 10);
            });
        }