public void IsNotEmptyTestCollectionGeneric()
        {
            ICollection argumentValue = new byte[] { 1, 2, 3 };
            string      argumentName  = string.Empty;

            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }

            argumentValue = null;
            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                Assert.Fail("Assert method must throw ArgumentException exception.");
            }
            catch (ArgumentException)
            {
                // test passed
            }
        }
        public void IsNotEmptyTestIn32()
        {
            int    argumentValue = 1;
            string argumentName  = string.Empty;

            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }

            argumentValue = 0;
            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                Assert.Fail("Assert method must throw ArgumentException exception.");
            }
            catch (ArgumentException)
            {
                // test passed
            }
        }
        /// <summary>
        ///A test for IsNotEmpty with generic dictionary param.
        ///</summary>
        public void IsNotEmptyTestGenericDictionaryHelper <TKey, TValue>() where TKey : class, new() where TValue : class, new()
        {
            IDictionary <TKey, TValue> argumentValue = new Dictionary <TKey, TValue>();

            argumentValue.Add(new TKey(), new TValue());
            string argumentName = string.Empty;

            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }

            argumentValue = null;
            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                Assert.Fail("Assert method must throw ArgumentException exception.");
            }
            catch (ArgumentException)
            {
                // test passed
            }
        }
        /// <summary>
        ///A test for IsNotEmpty with generic array param.
        ///</summary>
        public void IsNotEmptyTestGenericArrayHelper <T>() where T : class, new()
        {
            T[]    argumentValue = new T[] { new T() };
            string argumentName  = string.Empty;

            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }

            argumentValue = null;
            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                Assert.Fail("Assert method must throw ArgumentException exception.");
            }
            catch (ArgumentException)
            {
                // test passed
            }
        }
        /// <summary>
        ///A test for IsNotEmpty with generic <T> param.
        ///</summary>
        public void IsNotEmptyTestGerericHelper <T>() where T : class, new()
        {
            ICollection <T> argumentValue = new Collection <T>();

            argumentValue.Add(new T());
            string argumentName = string.Empty;

            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }

            argumentValue = null;
            try
            {
                ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                Assert.Fail("Assert method must throw ArgumentException exception.");
            }
            catch (ArgumentException)
            {
                // test passed
            }
        }
Exemple #6
0
 protected override void ValidateParameters()
 {
     ArgumentAssert.IsNotEmpty <SearchQuery>(QueryList, "QueryList");
     if (MaxQueries > 0)
     {
         ArgumentAssert.IsInRange(QueryList, 1, MaxQueries, "QueryList");
     }
     QueryList.ValidateParameters();
 }
 /// <summary>
 /// Open connection to Sphinx server
 /// </summary>
 public override void Open()
 {
     ArgumentAssert.IsNotEmpty(Host, "Host");
     // close existing connection, before opening new one
     Close();
     // reassign server endpoint address arguments
     Socket.Host = Host;
     Socket.Port = Port;
     Socket.ConnectionTimeout = ConnectionTimeout;
     Socket.Open();
 }
        public void Open()
        {
            ArgumentAssert.IsNotEmpty(Host, "Host");
            ArgumentAssert.IsInRange(Port, 1, UInt16.MaxValue, "Port");

            if (Connected)
            {
                Close();
            }
            if (Socket == null)
            {
                Socket = CreateSocket();
            }
            Socket.Connect(Host, Port);
        }
 /// <summary>
 /// Validate all command parameters.
 /// </summary>
 protected override void ValidateParameters()
 {
     ArgumentAssert.IsNotEmpty <string>(Documents, "Documents");
     ArgumentAssert.IsNotEmpty <string>(Keywords, "Keywords");
     ArgumentAssert.IsNotEmpty(Index, "Index");
     ArgumentAssert.IsNotNull(BeforeMatch, "BeforeMatch");
     ArgumentAssert.IsNotNull(AfterMatch, "AfterMatch");
     ArgumentAssert.IsNotNull(SnippetsDelimiter, "SnippetsDelimiter");
     ArgumentAssert.IsGreaterThan(SnippetSizeLimit, 0, "SnippetSizeLimit");
     ArgumentAssert.IsGreaterOrEqual(SnippetsCountLimit, 0, "SnippetsCountLimit");
     ArgumentAssert.IsGreaterOrEqual(WordsAroundKeyword, 0, "WordsAroundKeyword");
     ArgumentAssert.IsGreaterOrEqual(WordsCountLimit, 0, "WordsCountLimit");
     ArgumentAssert.IsDefinedInEnum(typeof(HtmlStripMode), HtmlStripMode, "HtmlStripMode");
     ArgumentAssert.IsDefinedInEnum(typeof(PassageBoundary), PassageBoundary, "PassageBoundary");
     ArgumentAssert.IsDefinedInEnum(typeof(BuildExcerptsOptions), Options, "Options");
 }
 public AttributeOverrideDateTime(string name, IDictionary <long, DateTime> values) : base(name)
 {
     ArgumentAssert.IsNotEmpty(values, "values");
     CollectionUtil.UnionDictionaries(_values, values);
 }
Exemple #11
0
 protected AttributeUpdateSinglePerDocumentBase(string name, IDictionary <long, T> values) : base(name)
 {
     ArgumentAssert.IsNotEmpty(values, "values");
     CollectionUtil.UnionDictionaries(_values, values);
 }
 protected override void ValidateParameters()
 {
     ArgumentAssert.IsNotEmpty <string>(Indexes, "Indexes");
     ArgumentAssert.IsNotEmpty(Query, "Query");
 }
 public AttributeUpdateMultiPerDocumentBase(string name, IDictionary <long, IEnumerable <T> > values) : base(name)
 {
     ArgumentAssert.IsNotEmpty(values, "values");
     CollectionUtil.UnionDictionaries(_values, values);
 }
 /// <summary>
 /// Validate all command parametrs.
 /// </summary>
 protected override void ValidateParameters()
 {
     ArgumentAssert.IsNotEmpty <string>(Indexes, "Indexes");
     ArgumentAssert.IsNotEmpty <AttributeUpdateBase>(AttributesValues, "AttributesValues");
 }