예제 #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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 internal AssertMessage(string name, AssertMessageParameterCollection parameters)
 {
     this.name       = name;
     this.parameters = parameters;
 }
예제 #7
0
 internal AssertMessage(string name)
 {
     this.name       = name;
     this.parameters = new AssertMessageParameterCollection();
 }