Ejemplo n.º 1
0
        public void Should_have_validation_error_when_template_name_is_empty()
        {
            var command = new CreateTemplate
            {
                Id          = Guid.NewGuid(),
                Name        = string.Empty,
                Description = "Description",
                ViewName    = "ViewName"
            };

            var templateRulesMock = new Mock <ITemplateRules>();
            var validator         = new CreateTemplateValidator(templateRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Ejemplo n.º 2
0
        public void Should_have_validation_error_when_template_name_is_not_unique()
        {
            var command = new CreateTemplate
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = "Description",
                ViewName    = "ViewName"
            };

            var templateRulesMock = new Mock <ITemplateRules>();

            templateRulesMock.Setup(x => x.IsTemplateNameUnique(command.Name, Guid.Empty)).Returns(false);

            var validator = new CreateTemplateValidator(templateRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Ejemplo n.º 3
0
        public void Should_have_validation_error_when_template_id_already_exists()
        {
            var command = new CreateTemplate
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = "Description",
                ViewName    = "ViewName"
            };

            var templateRulesMock = new Mock <ITemplateRules>();

            templateRulesMock.Setup(x => x.IsTemplateIdUnique(command.Id)).Returns(false);

            var siteRulesMock = new Mock <ISiteRules>();
            var validator     = new CreateTemplateValidator(templateRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Id, command);
        }
Ejemplo n.º 4
0
        public void Should_have_validation_error_when_template_name_is_too_long()
        {
            var name = "";

            for (int i = 0; i < 101; i++)
            {
                name += i;
            }

            var command = new CreateTemplate
            {
                Id          = Guid.NewGuid(),
                Name        = name,
                Description = "Description",
                ViewName    = "ViewName"
            };

            var templateRulesMock = new Mock <ITemplateRules>();
            var validator         = new CreateTemplateValidator(templateRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Ejemplo n.º 5
0
        public void Should_have_validation_error_when_description_is_too_long()
        {
            var description = "";

            for (int i = 0; i < 251; i++)
            {
                description += i;
            }

            var command = new CreateTemplate
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = description,
                ViewName    = "ViewName"
            };

            var templateRulesMock = new Mock <ITemplateRules>();
            var validator         = new CreateTemplateValidator(templateRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Description, command);
        }