コード例 #1
0
ファイル: TypedRows.cs プロジェクト: zhabis/nfx
        public void Validate_PersonWithNesting_Error_ComplexFieldRequired()
        {
            var person = new PersonWithNesting {
                ID           = "POP1",
                FirstName    = "Oleg",
                LastName     = "Popov",
                DOB          = new DateTime(1953, 12, 10),
                YearsInSpace = 45,
                Amount       = 100,
                History1     = new List <HistoryItem>(),
                // History2  = new HistoryItem[2]
            };
            var error = person.Validate();

            Console.WriteLine(error);
            Aver.IsTrue(error is CRUDFieldValidationException);
            Aver.AreEqual("History2", ((CRUDFieldValidationException)error).FieldName);
        }
コード例 #2
0
ファイル: TypedRows.cs プロジェクト: zhabis/nfx
        public void Validate_PersonWithNesting_Error_ComplexFieldSubFieldRequired()
        {
            var person = new PersonWithNesting {
                ID            = "POP1",
                FirstName     = "Oleg",
                LastName      = "Popov",
                DOB           = new DateTime(1953, 12, 10),
                YearsInSpace  = 45,
                Amount        = 100,
                LatestHistory = new HistoryItem {
                    ID = null, StartDate = DateTime.Now, Description = "Chaplin is here"
                },
                History1 = new List <HistoryItem>(),
                History2 = new HistoryItem[2]
            };
            var error = person.Validate();

            Console.WriteLine(error);
            Aver.IsTrue(error is CRUDFieldValidationException);
            Aver.AreEqual("ID", ((CRUDFieldValidationException)error).FieldName);
        }
コード例 #3
0
ファイル: TypedRows.cs プロジェクト: zhabis/nfx
        public void Validate_PersonWithNesting_Error_ComplexFieldCustomValidation()
        {
            var person = new PersonWithNesting {
                ID            = "POP1",
                FirstName     = "Oleg",
                LastName      = "Popov",
                DOB           = new DateTime(1953, 12, 10),
                YearsInSpace  = 45,
                Amount        = 100,
                LatestHistory = new HistoryItem {
                    ID = "111", StartDate = DateTime.Now, Description = "Someone is an idiot!"
                },
                History1 = new List <HistoryItem>(),
                History2 = new HistoryItem[2]
            };
            var error = person.Validate();

            Console.WriteLine(error);
            Aver.IsTrue(error is CRUDFieldValidationException);
            Aver.AreEqual("Description", ((CRUDFieldValidationException)error).FieldName);
            Aver.IsTrue(error.Message.Contains("Chaplin"));
        }