コード例 #1
0
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string       retStr       = "";
            Enums        enums        = new Enums(LanguageRequest);
            CSSPMPNTable cSSPMPNTable = validationContext.ObjectInstance as CSSPMPNTable;

            cSSPMPNTable.HasErrors = false;

            if (cSSPMPNTable.Tube10 < 0 || cSSPMPNTable.Tube10 > 5)
            {
                cSSPMPNTable.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Tube10", "0", "5"), new[] { "Tube10" }));
            }

            if (cSSPMPNTable.Tube1_0 < 0 || cSSPMPNTable.Tube1_0 > 5)
            {
                cSSPMPNTable.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Tube1_0", "0", "5"), new[] { "Tube1_0" }));
            }

            if (cSSPMPNTable.Tube0_1 < 0 || cSSPMPNTable.Tube0_1 > 5)
            {
                cSSPMPNTable.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Tube0_1", "0", "5"), new[] { "Tube0_1" }));
            }

            if (cSSPMPNTable.MPN < 0 || cSSPMPNTable.MPN > 100000000)
            {
                cSSPMPNTable.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "MPN", "0", "100000000"), new[] { "MPN" }));
            }

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                cSSPMPNTable.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
コード例 #2
0
        private CSSPMPNTable GetFilledRandomCSSPMPNTable(string OmitPropName)
        {
            CSSPMPNTable cSSPMPNTable = new CSSPMPNTable();

            if (OmitPropName != "Tube10")
            {
                cSSPMPNTable.Tube10 = GetRandomInt(0, 5);
            }
            if (OmitPropName != "Tube1_0")
            {
                cSSPMPNTable.Tube1_0 = GetRandomInt(0, 5);
            }
            if (OmitPropName != "Tube0_1")
            {
                cSSPMPNTable.Tube0_1 = GetRandomInt(0, 5);
            }
            if (OmitPropName != "MPN")
            {
                cSSPMPNTable.MPN = GetRandomInt(0, 100000000);
            }

            return(cSSPMPNTable);
        }
コード例 #3
0
 public CSSPMPNTableTest()
 {
     cSSPMPNTable = new CSSPMPNTable();
 }