Esempio n. 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);
     }
 }
Esempio n. 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);
            }
        }
        public static void Contains <T>(
            ICollection <T> collection,
            Func <T, bool> predicate,
            string collectionName,
            string predicateText)
        {
            Assert.IsNotNull(predicate != null);
            var enumerable  = (IEnumerable <T>)collection;
            var indexedItem = enumerable.IndexOf(predicate);
            int index       = indexedItem != null ? indexedItem.Index : -1;

            if (index < 0)
            {
                var message    = new AssertMessage("CollectionAssert.Contains");
                var parameters = message.Parameters;
                parameters.Add("collection", collection);
                parameters.Add("predicate", predicate);
                parameters.Add("collectionName", collectionName);
                parameters.Add("predicateText", predicateText);
                Assert.Raise(message);
            }
        }
 internal AssertFailedException(AssertMessage message)
 {
     this.message = message;
 }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public AssertFailedEventArgs(AssertMessage message)
 {
     this.message = message;
 }