Ejemplo n.º 1
0
        public void AllNegative()
        {
            var expected = new NotificationAssertion();
            expected.RegisterMessage("Name", Notification.REQUIRED_FIELD, Severity.Error);
            expected.RegisterMessage("Amount", Notification.REQUIRED_FIELD, Severity.Error);
            expected.RegisterMessage("TradeDate", Notification.REQUIRED_FIELD, Severity.Error);

            var target = new RequiredPropertyTarget();

            var actual = Validator.ValidateObject(target);
            expected.AssertEquals(actual);
        }
Ejemplo n.º 2
0
        public void AllPositive2()
        {
            var expected = new NotificationAssertion();

            var target = new RequiredPropertyTarget();
            target.Amount =0;
            target.Name = "Jeremy";

            target.TradeDate = DateTime.Now;

            var actual = Validator.ValidateObject(target);
            expected.AssertEquals(actual);
        }
Ejemplo n.º 3
0
        public void Customize_the_message_builder()
        {
            RequiredAttribute.GetMessage = (att, prop) => prop.Name + " is required";

            var expected = new NotificationAssertion();
            expected.RegisterMessage("Name", "Name is required", Severity.Error);
            expected.RegisterMessage("Amount", "Amount is required", Severity.Error);
            expected.RegisterMessage("TradeDate", "TradeDate is required", Severity.Error);

            var target = new RequiredPropertyTarget();

            var actual = Validator.ValidateObject(target);
            expected.AssertEquals(actual);
        }
Ejemplo n.º 4
0
        public void Empty_string_fails_validation()
        {
            var expected = new NotificationAssertion();
            expected.RegisterMessage("Name", Notification.REQUIRED_FIELD, Severity.Error);

            var target = new RequiredPropertyTarget(){Amount = 3, TradeDate = DateTime.Today, Name = string.Empty};

            var actual = Validator.ValidateObject(target);
            expected.AssertEquals(actual);
        }