示例#1
0
        public void Succeed_NullString()
        {
            const string s      = null;
            var          result = ArgumentUtility.CheckNotEmpty("arg", s);

            Assert.That(result, Is.Null);
        }
        /// <summary>
        /// Creates a <see cref="CommandInfo"/> for a postback-based command.
        /// </summary>
        /// <param name="title">The <see cref="string"/> displayed as the commands title. Must not be empty.</param>
        /// <param name="accessKey">The <see cref="char"/> to use for keyboard-shortcut navigation.</param>
        /// <param name="onClick">The javascript hooked up to the click event. Must not be <see langword="null" /> or empty.</param>
        public static CommandInfo CreateForPostBack(string title, string accessKey, string onClick)
        {
            ArgumentUtility.CheckNotEmpty("title", title);
            ArgumentUtility.CheckNotNullOrEmpty("onClick", onClick);

            return(new CommandInfo(title, accessKey, "#", null, onClick));
        }
示例#3
0
        public SqlRowNumberExpression(Ordering[] orderings)
        {
            ArgumentUtility.CheckNotNull("orderings", orderings);
            ArgumentUtility.CheckNotEmpty("orderings", orderings);

            _orderings = Array.AsReadOnly(orderings);
        }
示例#4
0
        public SqlIndexDefinition(
            string indexName,
            IEnumerable <SqlIndexedColumnDefinition> columns,
            IEnumerable <ColumnDefinition> includedColumns = null,
            bool?isClustered           = false,
            bool?isUnique              = false,
            bool?ignoreDupKey          = null,
            bool?online                = null,
            bool?padIndex              = null,
            int?fillFactor             = null,
            bool?sortInTempDb          = null,
            bool?statisticsNoReCompute = null,
            bool?dropExisting          = null,
            bool?allowRowLocks         = null,
            bool?allowPageLocks        = null,
            int?maxDop = null)
            : base(padIndex, fillFactor, sortInTempDb, statisticsNoReCompute, dropExisting, allowRowLocks, allowPageLocks, maxDop)
        {
            ArgumentUtility.CheckNotNullOrEmpty("indexName", indexName);
            ArgumentUtility.CheckNotNullOrEmpty("columns", columns);
            ArgumentUtility.CheckNotEmpty("includedColumns", includedColumns);

            _indexName = indexName;
            _columns   = columns.ToList().AsReadOnly();
            if (includedColumns != null)
            {
                _includedColumns = includedColumns.ToList().AsReadOnly();
            }
            _isClustered  = isClustered;
            _isUnique     = isUnique;
            _ignoreDupKey = ignoreDupKey;
            _online       = online;
        }
示例#5
0
        public void Succeed_NonEmptyGuid()
        {
            Guid guid   = Guid.NewGuid();
            var  result = ArgumentUtility.CheckNotEmpty("arg", guid);

            Assert.That(result, Is.EqualTo(guid));
        }
        public EntityNameDefinition(string schemaName, string entityName)
        {
            ArgumentUtility.CheckNotEmpty("schemaName", schemaName);
            ArgumentUtility.CheckNotNullOrEmpty("entityName", entityName);

            _schemaName = schemaName;
            _entityName = entityName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityPrincipalRole"/> type.
        /// </summary>
        /// <param name="group">The group the user is a member of when he is this role. Must not be <see langword="null" /> or empty.</param>
        /// <param name="position">The position in the <paramref name="group"/>. Must not be empty.</param>
        public SecurityPrincipalRole(string group, string position)
        {
            ArgumentUtility.CheckNotNullOrEmpty("group", group);
            ArgumentUtility.CheckNotEmpty("position", position);

            _group    = group;
            _position = position;
        }
示例#8
0
        public DomainPropertyControlSelectionCommandBuilder([NotNull] string domainProperty, [CanBeNull] string domainClass = null)
        {
            ArgumentUtility.CheckNotNullOrEmpty("domainProperty", domainProperty);
            ArgumentUtility.CheckNotEmpty("domainClass", domainClass);

            _domainProperty = domainProperty;
            _domainClass    = domainClass;
        }
        /// <summary>
        /// Creates a <see cref="CommandInfo"/> for a hyperlink-based command.
        /// </summary>
        /// <param name="title">The text displayed as the command's title. Must not be empty.</param>
        /// <param name="accessKey">The <see cref="char"/> to use for keyboard-shortcut navigation.</param>
        /// <param name="href">The url to be opened when the command is clicked. Must not be <see langword="null" /> or empty.</param>
        /// <param name="target">The target where the url is opened.  Must not be empty.</param>
        /// <param name="onClick">An optional javascript hooked up to the click event. The script is only allowed to do housekeeping. Must not be empty.</param>
        public static CommandInfo CreateForLink(string title, string accessKey, string href, string target, string onClick)
        {
            ArgumentUtility.CheckNotEmpty("title", title);
            ArgumentUtility.CheckNotNullOrEmpty("href", href);
            ArgumentUtility.CheckNotEmpty("target", target);
            ArgumentUtility.CheckNotEmpty("onClick", onClick);

            return(new CommandInfo(title, accessKey, href, target, onClick));
        }
示例#10
0
        public DomainPropertyControlSelectionCommand(
            [NotNull] IDomainPropertyControlSelector <TControlObject> controlSelector,
            [NotNull] string domainProperty,
            [CanBeNull] string domainClass = null)
        {
            ArgumentUtility.CheckNotNull("controlSelector", controlSelector);
            ArgumentUtility.CheckNotNullOrEmpty("domainProperty", domainProperty);
            ArgumentUtility.CheckNotEmpty("domainClass", domainClass);

            _controlSelector = controlSelector;
            _domainProperty  = domainProperty;
            _domainClass     = domainClass;
        }
示例#11
0
        /// <summary>
        /// Extension method for selecting a control by the domain property it represetns (using the
        /// <see cref="DomainPropertyControlSelectionCommandBuilder{TControlSelector,TControlObject}"/>).
        /// </summary>
        public static TControlObject ByDomainProperty <TControlSelector, TControlObject> (
            [NotNull] this IFluentControlSelector <TControlSelector, TControlObject> fluentControlSelector,
            [NotNull] string domainProperty,
            [CanBeNull] string domainClass = null)
            where TControlSelector : IDomainPropertyControlSelector <TControlObject>
            where TControlObject : ControlObject
        {
            ArgumentUtility.CheckNotNull("fluentControlSelector", fluentControlSelector);
            ArgumentUtility.CheckNotNullOrEmpty("domainProperty", domainProperty);
            ArgumentUtility.CheckNotEmpty("domainClass", domainClass);

            return(fluentControlSelector.GetControl(
                       new DomainPropertyControlSelectionCommandBuilder <TControlSelector, TControlObject> (domainProperty, domainClass)));
        }
示例#12
0
        public SecurityPrincipal(string user, ISecurityPrincipalRole role, string substitutedUser, ISecurityPrincipalRole substitutedRole)
        {
            ArgumentUtility.CheckNotNullOrEmpty("user", user);
            ArgumentUtility.CheckNotEmpty("substitutedUser", substitutedUser);
            if (substitutedRole != null && substitutedUser == null)
            {
                throw new ArgumentException("The substituted user must be specified if a substituted role is also specified.", "substitutedUser");
            }

            _user            = user;
            _substitutedRole = substitutedRole;
            _substitutedUser = substitutedUser;
            _role            = role;
        }
示例#13
0
        public UnionViewDefinition(
            StorageProviderDefinition storageProviderDefinition,
            EntityNameDefinition viewName,
            IEnumerable <IRdbmsStorageEntityDefinition> unionedEntities,
            ObjectIDStoragePropertyDefinition objectIDProperty,
            IRdbmsStoragePropertyDefinition timestampProperty,
            IEnumerable <IRdbmsStoragePropertyDefinition> dataProperties,
            IEnumerable <IIndexDefinition> indexes,
            IEnumerable <EntityNameDefinition> synonyms)
            : base(
                storageProviderDefinition,
                viewName,
                objectIDProperty,
                timestampProperty,
                dataProperties,
                indexes,
                synonyms)
        {
            ArgumentUtility.CheckNotNull("unionedEntities", unionedEntities);

            var unionedEntitiesList = unionedEntities.ToList().AsReadOnly();

            ArgumentUtility.CheckNotEmpty("unionedEntities", unionedEntitiesList);

            for (int i = 0; i < unionedEntitiesList.Count; ++i)
            {
                var unionedEntity = unionedEntitiesList[i];
                if (!(unionedEntity is TableDefinition || unionedEntity is UnionViewDefinition))
                {
                    throw new ArgumentException(
                              string.Format(
                                  "Item {0} is of type '{1}', but the unioned entities must either be a TableDefinitions or UnionViewDefinitions.",
                                  i,
                                  unionedEntity.GetType()),
                              "unionedEntities");
                }
            }

            _unionedEntities = unionedEntitiesList;
        }
示例#14
0
        private void CheckValue(string argumentName, object value)
        {
            Type valueType = value.GetType();

            if (valueType != typeof(Guid) && valueType != typeof(int) && valueType != typeof(string))
            {
                throw CreateArgumentException(argumentName, "Remotion.Data.DomainObjects.ObjectID does not support values of type '{0}'.", valueType);
            }

            if (valueType == typeof(string))
            {
                ObjectIDStringSerializer.Instance.CheckSerializableStringValue((string)value);
            }

            if (valueType == typeof(string))
            {
                ArgumentUtility.CheckNotEmpty(argumentName, (string)value);
            }

            if (valueType == typeof(Guid))
            {
                ArgumentUtility.CheckNotEmpty(argumentName, (Guid)value);
            }
        }
 public void SetAdditionalCssClassForDataRow(string cssClass)
 {
     ArgumentUtility.CheckNotEmpty("cssClass", cssClass);
     _additionalCssClassForDataRow = cssClass;
 }
示例#16
0
        public void Succeed_NonEmptyString()
        {
            var result = ArgumentUtility.CheckNotEmpty("arg", "x");

            Assert.That(result, Is.EqualTo("x"));
        }
示例#17
0
 public void Fail_EmptyString()
 {
     ArgumentUtility.CheckNotEmpty("arg", "");
 }
示例#18
0
 public void Fail_EmptyGuid()
 {
     ArgumentUtility.CheckNotEmpty("arg", Guid.Empty);
 }
示例#19
0
        public void Succeed_NonEmptyCollection()
        {
            var result = ArgumentUtility.CheckNotEmpty("arg", new[] { 1 });

            Assert.That(result, Is.EqualTo(new[] { 1 }));
        }
示例#20
0
 public void Fail_EmptyCollection()
 {
     ArgumentUtility.CheckNotEmpty("arg", Type.EmptyTypes);
 }
示例#21
0
        public void Succeed_NullCollection()
        {
            var result = ArgumentUtility.CheckNotEmpty("arg", (IEnumerable)null);

            Assert.That(result, Is.Null);
        }