示例#1
0
 public static void IsNotNullAndNotWhiteSpace(string value, string name)
 {
     if (value.IsNullOrWhiteSpace())
     {
         AssertMessage message = new AssertMessage("StringAssert.IsNotNullAndNotWhiteSpace");
         AssertMessageParameterCollection parameters = message.Parameters;
         parameters.Add("name", name);
         parameters.Add("value", value);
         Assert.Raise(message);
     }
 }
示例#2
0
 public static void IsNullOrEmpty(string value, string name)
 {
     if (!string.IsNullOrEmpty(value))
     {
         var message = new AssertMessage("StringAssert.IsNullOrEmpty");
         AssertMessageParameterCollection parameters = message.Parameters;
         parameters.Add("name", name);
         parameters.Add("value", value);
         Assert.Raise(message);
     }
 }
        public static void Contains(
            IDictionary dictionary,
            object key,
            string dictionaryName,
            string keyName)
        {
            Assert.IsNotNull(dictionary != null);
            bool containsKey = dictionary.Contains(key);

            if (!containsKey)
            {
                AssertMessage message = new AssertMessage("CollectionAssert.ContainsKey");
                AssertMessageParameterCollection parameters = message.Parameters;
                parameters.Add("dictionary", dictionary);
                parameters.Add("dictionaryName", dictionaryName);
                parameters.Add("key", key);
                parameters.Add("keyName", keyName);
                Assert.Raise(message);
            }
        }
        public static void Contains <T>(
            ICollection <T> collection,
            T item,
            string collectionName,
            string itemName)
        {
            Assert.IsNotNull(collection != null);
            bool contains = collection.Contains(item);

            if (!contains)
            {
                AssertMessage message = new AssertMessage("CollectionAssert.Contains");
                AssertMessageParameterCollection parameters = message.Parameters;
                parameters.Add("collection", collection);
                parameters.Add("item", item);
                parameters.Add("collectionName", collectionName);
                parameters.Add("itemName", itemName);
                Assert.Raise(message);
            }
        }
        public static void NotContainsKey <TKey, TValue>(
            IDictionary <TKey, TValue> dictionary,
            TKey key,
            string dictionaryName,
            string keyName)
        {
            Assert.IsNotNull(dictionary != null);
            bool containsKey = dictionary.ContainsKey(key);

            if (containsKey)
            {
                var message = new AssertMessage("CollectionAssert.NotContainsKey");
                AssertMessageParameterCollection parameters = message.Parameters;
                parameters.Add("dictionary", dictionary);
                parameters.Add("dictionaryName", dictionaryName);
                parameters.Add("key", key);
                parameters.Add("keyName", keyName);
                Assert.Raise(message);
            }
        }