Example #1
0
        public void Name_Is_Required()
        {
            Models.Attribute attribute = new Models.Attribute
            {
            };

            IList <System.ComponentModel.DataAnnotations.ValidationResult> result = attribute.ValidateModel();

            Assert.Collection(result, x => Assert.Contains("Name", x.ErrorMessage));
        }
Example #2
0
        public void ModifiedMaximum_NotValid_If_Less_Than_Maximim()
        {
            Models.Attribute attribute = new Models.Attribute
            {
                Name            = "Bob",
                Maximum         = 2,
                ModifiedMaximum = 1
            };

            IList <System.ComponentModel.DataAnnotations.ValidationResult> result = attribute.ValidateModel();

            Assert.Collection(result, x => Assert.Equal("Modified Maximum must be greater than or equal to Maximum", x.ErrorMessage));
        }
Example #3
0
        public void ValidModel_Passes()
        {
            Models.Attribute attribute = new Models.Attribute
            {
                Name            = "Bob",
                ModifiedMinimum = 2,
                Minimum         = 2,
                Maximum         = 3,
                ModifiedMaximum = 3
            };

            IList <System.ComponentModel.DataAnnotations.ValidationResult> result = attribute.ValidateModel();

            Assert.Empty(result);
        }
Example #4
0
        public void Minimum_NotValid_If_Greater_Than_Maximim()
        {
            Models.Attribute attribute = new Models.Attribute
            {
                Name            = "Bob",
                Minimum         = 1,
                ModifiedMinimum = 4,
                Maximum         = 2,
                ModifiedMaximum = 5
            };

            IList <System.ComponentModel.DataAnnotations.ValidationResult> result = attribute.ValidateModel();

            Assert.Collection(result, x => Assert.Collection(x.MemberNames,
                                                             firstMemberName => Assert.Equal("ModifiedMinimum", firstMemberName),
                                                             secondMemberName => Assert.Equal("Minimum", secondMemberName)
                                                             ));
        }