public void UsedOnWrongTypeShouldThrow()
        {
            // the attribute should be used only types that implement IList
            // so if the attribute is used on an incorrect type the developer should get feedback and not say everything is ok
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            Action act = () => attr.IsValid("NotAnIList");

            act.ShouldThrow <Exception>("Because attribute is used on a wrong type (should be used only on types that implement IList).");
        }
        public void AllowOnlyStringsInList()
        {
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            List <int> inValues = new List <int>(3)
            {
                10, 100, 151
            };

            attr.IsValid(inValues).Should().BeFalse();
        }
        public void ForbiddenValueInList()
        {
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            List <string> inValues = new List <string>(4)
            {
                "ptv", "question", " ", "vrk"
            };

            attr.IsValid(inValues).Should().BeFalse();
        }
        public void NullValueInListIsNotValid()
        {
            // null values are not allowed in list
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            List <string> inValues = new List <string>()
            {
                "ptv", "some long string", null
            };

            attr.IsValid(inValues).Should().BeFalse();
        }
        public void ForbiddenValueInCustomObjectList()
        {
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk", "String");

            List <SomeDemoObject> inValues = new List <SomeDemoObject>()
            {
                new SomeDemoObject()
                {
                    Integer = 10,
                    String  = "text"
                },
                new SomeDemoObject()
                {
                    Integer = 100,
                    String  = "vrk"
                }
            };

            attr.IsValid(inValues).Should().BeFalse();
        }
        public void EmptyListIsValidationSuccess()
        {
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            attr.IsValid(new List <string>()).Should().BeTrue();
        }
        public void NullListIsValidationSuccess()
        {
            ListPropertyForbiddenValueAttribute attr = new ListPropertyForbiddenValueAttribute("vrk");

            attr.IsValid(null).Should().BeTrue();
        }