Example #1
0
        public void AllItemsAreNotNull_Collection_Does_Not_Contain_Null_Does_Not_Throw_Exception()
        {
            IList <string> list = new List <string>()
            {
                "a", "b", "c"
            };

            Insist.AllItemsAreNotNull(list, "list");
        }
Example #2
0
 public void AllItemsAreNotNull_Thrown_Exception_Has_Correct_Message()
 {
     try
     {
         IList <string> list = new List <string>()
         {
             "a", "b", null, "c"
         };
         Insist.AllItemsAreNotNull(list, ARGUMENT_NAME, MESSAGE);
     }
     catch (ArgumentException ae)
     {
         Assert.IsTrue(ae.Message.Contains(MESSAGE));
     }
 }
Example #3
0
 public void AllItemsAreNotNull_Thrown_Exception_Has_Correct_Argument_Name()
 {
     try
     {
         IList <string> list = new List <string>()
         {
             "a", "b", null, "c"
         };
         Insist.AllItemsAreNotNull(list, ARGUMENT_NAME);
     }
     catch (ArgumentException ae)
     {
         Assert.AreEqual(ARGUMENT_NAME, ae.ParamName);
     }
 }
        /// <summary>
        /// Creates a new ThreadShared resource
        /// </summary>
        /// <param name="firstMandatoryLock">
        /// All ThreadShared resources MUST be associated with at least 1 lock
        /// </param>
        /// <param name="otherLocks">
        /// Some resources need to be protected by more than 1 lock, specify
        /// all the other padlocks that protect this resource here.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown if FirstMandatorLock is null
        /// </exception>
        protected BaseThreadShared(Padlock firstMandatoryLock, params Padlock[] otherLocks)
        {
            Insist.IsNotNull(firstMandatoryLock, "firstMandatoryLock");
            Insist.AllItemsAreNotNull(otherLocks, "otherLocks");

            _associatedPadlocks = new Dictionary <Padlock, int>();
            _associatedPadlocks.Add(firstMandatoryLock, 0);

            foreach (Padlock currentPadlock in otherLocks)
            {
                _associatedPadlocks.Add(currentPadlock, 0);
            }

            //Register this ThreadShared resource with all of the associated Padlocks.
            foreach (Padlock currentPadlock in _associatedPadlocks.Keys)
            {
                currentPadlock.Register(this);
            }
        }
Example #5
0
        public void AllItemsAreNotNull_Empty_Collection_Does_Not_Throw_Exception()
        {
            IList <string> list = new List <string>();

            Insist.AllItemsAreNotNull(list, "list");
        }
Example #6
0
        public void AllItemsAreNotNull_Null_Collection_Throws_Exception()
        {
            IList <string> list = null;

            Insist.AllItemsAreNotNull(list, "list");
        }