Ejemplo n.º 1
0
        public void CanAdd_should_not_throw_exception_if_command_is_valid()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = ".*"
            };

            GuardAppPatterns.CanAdd(patterns_0, command);
        }
Ejemplo n.º 2
0
        public void CanDelete_should_throw_exception_if_pattern_not_found()
        {
            var command = new DeletePattern {
                PatternId = patternId
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppPatterns.CanDelete(patterns_0, command));
        }
Ejemplo n.º 3
0
        public void CanUpdate_should_throw_exception_if_pattern_does_not_exists()
        {
            var command = new UpdatePattern {
                PatternId = patternId, Name = "Pattern1", Pattern = ".*"
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppPatterns.CanUpdate(patterns_0, command));
        }
Ejemplo n.º 4
0
        public void CanAdd_should_throw_exception_if_pattern_not_valid()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = "[0-9{1}"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_0, command),
                                    new ValidationError("Pattern is not a valid value.", "Pattern"));
        }
Ejemplo n.º 5
0
        public void CanAdd_should_throw_exception_if_pattern_empty()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = string.Empty
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_0, command),
                                    new ValidationError("Pattern is required.", "Pattern"));
        }
Ejemplo n.º 6
0
        public void CanAdd_should_throw_exception_if_name_empty()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = string.Empty, Pattern = ".*"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(command, App(patterns_0)),
                                    new ValidationError("Name is required.", "Name"));
        }
Ejemplo n.º 7
0
        public void CanUpdate_should_not_throw_exception_if_pattern_exist_with_valid_command()
        {
            var patterns_1 = patterns_0.Add(patternId, "any", ".*", "Message");

            var command = new UpdatePattern {
                PatternId = patternId, Name = "Pattern1", Pattern = ".*"
            };

            GuardAppPatterns.CanUpdate(patterns_1, command);
        }
Ejemplo n.º 8
0
        public void CanDelete_should_not_throw_exception_if_command_is_valid()
        {
            var patterns_1 = patterns_0.Add(patternId, "any", ".*", "Message");

            var command = new DeletePattern {
                PatternId = patternId
            };

            GuardAppPatterns.CanDelete(patterns_1, command);
        }
Ejemplo n.º 9
0
        public void CanAdd_should_throw_exception_if_pattern_exists()
        {
            var patterns_1 = patterns_0.Add(DomainId.NewGuid(), "any", "[a-z]", "Message");

            var command = new AddPattern {
                PatternId = patternId, Name = "other", Pattern = "[a-z]"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_1, command),
                                    new ValidationError("This pattern already exists but with another name."));
        }
Ejemplo n.º 10
0
        public void CanAdd_should_throw_exception_if_name_exists()
        {
            var patterns_1 = patterns_0.Add(DomainId.NewGuid(), "any", "[a-z]", "Message");

            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = ".*"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_1, command),
                                    new ValidationError("A pattern with the same name already exists."));
        }
Ejemplo n.º 11
0
        public void CanUpdate_should_throw_exception_if_pattern_not_valid()
        {
            var patterns_1 = patterns_0.Add(patternId, "any", ".*", "Message");

            var command = new UpdatePattern {
                PatternId = patternId, Name = "any", Pattern = "[0-9{1}"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanUpdate(patterns_1, command),
                                    new ValidationError("Pattern is not a valid value.", "Pattern"));
        }
Ejemplo n.º 12
0
        public void CanUpdate_should_throw_exception_if_pattern_empty()
        {
            var patterns_1 = patterns_0.Add(patternId, "any", ".*", "Message");

            var command = new UpdatePattern {
                PatternId = patternId, Name = "any", Pattern = string.Empty
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanUpdate(patterns_1, command),
                                    new ValidationError("Pattern is required.", "Pattern"));
        }
Ejemplo n.º 13
0
        public void CanUpdate_should_throw_exception_if_name_empty()
        {
            var patterns_1 = patterns_0.Add(patternId, "any", ".*", "Message");

            var command = new UpdatePattern {
                PatternId = patternId, Name = string.Empty, Pattern = ".*"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanUpdate(command, App(patterns_1)),
                                    new ValidationError("Name is required.", "Name"));
        }
Ejemplo n.º 14
0
        public void CanUpdate_should_throw_exception_if_pattern_exists()
        {
            var id1 = DomainId.NewGuid();
            var id2 = DomainId.NewGuid();

            var patterns_1 = patterns_0.Add(id1, "Pattern1", "[0-5]", "Message");
            var patterns_2 = patterns_1.Add(id2, "Pattern2", "[0-4]", "Message");

            var command = new UpdatePattern {
                PatternId = id2, Name = "Pattern2", Pattern = "[0-5]"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanUpdate(patterns_2, command),
                                    new ValidationError("This pattern already exists but with another name."));
        }
Ejemplo n.º 15
0
        public void CanUpdate_should_throw_exception_if_name_exists()
        {
            var id1 = DomainId.NewGuid();
            var id2 = DomainId.NewGuid();

            var patterns_1 = patterns_0.Add(id1, "Pattern1", "[0-5]", "Message");
            var patterns_2 = patterns_1.Add(id2, "Pattern2", "[0-4]", "Message");

            var command = new UpdatePattern {
                PatternId = id2, Name = "Pattern1", Pattern = "[0-4]"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanUpdate(command, App(patterns_2)),
                                    new ValidationError("A pattern with the same name already exists."));
        }