コード例 #1
0
        public void CanUpdateSettings_should_throw_exception_if_settings_is_null()
        {
            var command = new UpdateAppSettings();

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Settings is required.", "Settings"));
        }
コード例 #2
0
        public void CanUpdateSettings_should_throw_exception_if_editors_is_null()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = null !
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Editors is required.", "Settings.Editors"));
        }
コード例 #3
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_url()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = ReadonlyList.Create(
                        new Editor("name", null !))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Url is required.", "Settings.Editors[0].Url"));
        }
コード例 #4
0
        public void CanUpdateSettings_should_throw_exception_if_editors_has_null_name()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = ReadonlyList.Create(
                        new Editor(null !, "[a-z]"))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Name is required.", "Settings.Editors[0].Name"));
        }
コード例 #5
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_regex()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadonlyList.Create(
                        new Pattern("name", null !))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Regex is required.", "Settings.Patterns[0].Regex"));
        }
コード例 #6
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_name()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadOnlyCollection.Create(
                        new Pattern(null !, "[a-z]"))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Name is required.", "Settings.Patterns[0].Name"));
        }
コード例 #7
0
        public void CanUpdateSettings_should_not_throw_exception_if_setting_is_valid()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadonlyList.Create(
                        new Pattern("name", "[a-z]")),
                    Editors = ReadonlyList.Create(
                        new Editor("name", "url/to/editor"))
                }
            };

            GuardApp.CanUpdateSettings(command);
        }