コード例 #1
0
        public void CanDelete_should_throw_exception_if_pattern_not_found()
        {
            var command = new DeletePattern {
                PatternId = patternId
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppPatterns.CanDelete(command, App(patterns_0)));
        }
コード例 #2
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(command, App(patterns_0)));
        }
コード例 #3
0
        public void CanAdd_should_not_throw_exception_if_command_is_valid()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = ".*"
            };

            GuardAppPatterns.CanAdd(command, App(patterns_0));
        }
コード例 #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(command, App(patterns_0)),
                                    new ValidationError("Pattern is not a valid value.", "Pattern"));
        }
コード例 #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(command, App(patterns_0)),
                                    new ValidationError("Pattern is required.", "Pattern"));
        }
コード例 #6
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(command, App(patterns_1));
        }
コード例 #7
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(command, App(patterns_1));
        }
コード例 #8
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(command, App(patterns_1)),
                                    new ValidationError("This pattern already exists but with another name."));
        }
コード例 #9
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(command, App(patterns_1)),
                                    new ValidationError("A pattern with the same name already exists."));
        }
コード例 #10
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(command, App(patterns_1)),
                                    new ValidationError("Pattern is not a valid value.", "Pattern"));
        }
コード例 #11
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(command, App(patterns_1)),
                                    new ValidationError("Pattern is required.", "Pattern"));
        }
コード例 #12
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(command, App(patterns_2)),
                                    new ValidationError("This pattern already exists but with another name."));
        }