public void NotPassWithRequiredEmptyString()
        {
            var model = new RequiredModel()
            {
                Summary = string.Empty,
            };

            NotPass(model);
        }
        public void NotPassRequired()
        {
            var model = new RequiredModel
            {
                Summary = string.Empty,
            };

            var actionContext = ValidatorUtils.CreateActionContext();

            _validator.Validate(actionContext, null, string.Empty, model);

            Assert.False(actionContext.ModelState.IsValid);
            Assert.NotEmpty(actionContext.ModelState);
        }
        public void PassRequired()
        {
            var model = new RequiredModel
            {
                Summary = Guid.NewGuid().ToString(),
            };

            var actionContext = ValidatorUtils.CreateActionContext();

            _validator.Validate(actionContext, null, string.Empty, model);

            Assert.True(actionContext.ModelState.IsValid);
            Assert.Empty(actionContext.ModelState);
        }
        public void PassWithRequired()
        {
            var container = new RequiredModel()
            {
                Summary = "Hello",
            };
            var model = container.Summary;

            var context = GetMockedValidationContextForModel(model, container);

            var result = _validator.Validate(context);

            Assert.Empty(result);
        }
        public void NotPassWithRequired()
        {
            var container = new RequiredModel()
            {
                Summary = string.Empty,
            };
            var model = container.Summary;

            var context = GetMockedValidationContextForModel(model, container);

            var result = _validator.Validate(context);

            Assert.NotEmpty(result);

            var validationResult = result.Single();

            // This is a validation at type level, and the membername will be setted to empty.
            Assert.Empty(validationResult.MemberName);
            Assert.Equal(new RequiredAttribute().FormatErrorMessage("Summary"), validationResult.Message);
        }
        public void NotPassWithNullString()
        {
            var model = new RequiredModel();

            NotPass(model);
        }