Exemple #1
0
        public void Should_have_validation_error_when_menu_name_is_empty()
        {
            var command = new CreateMenu
            {
                SiteId = Guid.NewGuid(),
                Id     = Guid.NewGuid(),
                Name   = ""
            };

            var menuRulesMock = new Mock <IMenuRules>();
            var siteRulesMock = new Mock <ISiteRules>();

            var validator = new CreateMenuValidator(menuRulesMock.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Exemple #2
0
        public void Should_have_validation_error_when_site_does_not_exist()
        {
            var command = new CreateMenu
            {
                SiteId = Guid.NewGuid(),
                Id     = Guid.NewGuid(),
                Name   = "My Menu"
            };

            var menuRulesMock = new Mock <IMenuRules>();

            var siteRulesMock = new Mock <ISiteRules>();

            siteRulesMock.Setup(x => x.DoesSiteExist(command.SiteId)).Returns(false);

            var validator = new CreateMenuValidator(menuRulesMock.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.SiteId, command);
        }
Exemple #3
0
        public void Should_have_validation_error_when_menu_name_is_not_valid()
        {
            var command = new CreateMenu
            {
                SiteId = Guid.NewGuid(),
                Id     = Guid.NewGuid(),
                Name   = "My@Menu"
            };

            var menuRulesMock = new Mock <IMenuRules>();

            menuRulesMock.Setup(x => x.IsMenuNameValid(command.Name)).Returns(false);

            var siteRulesMock = new Mock <ISiteRules>();

            var validator = new CreateMenuValidator(menuRulesMock.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Exemple #4
0
        public void Should_have_validation_error_when_menu_id_already_exists()
        {
            var command = new CreateMenu
            {
                SiteId = Guid.NewGuid(),
                Id     = Guid.NewGuid(),
                Name   = "My Menu"
            };

            var menuRulesMock = new Mock <IMenuRules>();

            menuRulesMock.Setup(x => x.IsMenuIdUnique(command.Id)).Returns(false);

            var siteRulesMock = new Mock <ISiteRules>();

            var validator = new CreateMenuValidator(menuRulesMock.Object, siteRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Id, command);
        }
Exemple #5
0
        public void Should_have_validation_error_when_menu_name_is_too_long()
        {
            var name = "";

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

            var command = new CreateMenu
            {
                SiteId = Guid.NewGuid(),
                Id     = Guid.NewGuid(),
                Name   = name
            };

            var menuRulesMock = new Mock <IMenuRules>();
            var siteRulesMock = new Mock <ISiteRules>();

            var validator = new CreateMenuValidator(menuRulesMock.Object, siteRulesMock.Object);

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