Example #1
0
 public void ToHexNegativeIntPUT(int actual)
 {
     PexAssume.IsTrue(actual < 0);
     try
     {
         actual.ToHex();
         PexAssert.IsFalse(true);
     }
     catch (ArgumentOutOfRangeException ex)
     {
         PexGoal.Reached();
     }
 }
Example #2
0
        public void PeekBackEmptyDequePUT([PexAssumeUnderTest] Collection <int> values)
        {
            Deque <int> actual = new Deque <int>(values);

            try
            {
                actual.PeekBack();
            }
            catch (InvalidOperationException ex)
            {
                PexGoal.Reached();
            }
        }
Example #3
0
 /// Summary
 /// Time: 4 min 7 sec
 /// Pattern: AAA, AllowedException, State relation, Reachablility
 /// Combines three unit tests into one
 public void ArgumentNullParamNameIsNotTest(string s1, string s2)
 {
     try
     {
         Guard.ArgumentNull(s1, s2);
     }
     catch (ArgumentNullException e)
     {
         PexGoal.Reached();  //Makes sure that the goal is reached
         if (s2 == null)
         {
             PexAssert.AreEqual("parameterName", e.ParamName);
         }
         throw;
     }
 }
Example #4
0
 /// Summary
 /// Time: 5 min 2 sec
 /// Pattern: AAA, AllowedException, Reachablility
 /// Combines three unit tests into one. Also uses the feature of multiple goals
 public void InvalidOperationConditionTrueTest(int x1, int x2, string message)
 {
     try
     {
         Guard.InvalidOperation(x1 < x2, message);
     }
     catch (InvalidOperationException)
     {
         PexGoal.Reached("InvalidOperation");
         throw;
     }
     catch (ArgumentNullException)
     {
         PexGoal.Reached("ArgumentNull");
         throw;
     }
     PexGoal.Reached("normalgoal");
 }
Example #5
0
 /// Summary
 /// Time: 3 min 30 sec
 /// Pattern: AAA, AllowedException, Reachablility
 /// Combines three unit tests into one. Also uses the feature of multiple goals
 public void ArgumentOutOfRangeConditionTrueTest(int x1, int x2, string message1, string message2)
 {
     try
     {
         Guard.OutOfRange(x1 < x2, message1, message2);
     }
     catch (ArgumentOutOfRangeException)
     {
         PexGoal.Reached("ArgumentOut");
         throw;
     }
     catch (ArgumentNullException)
     {
         PexGoal.Reached("ArgumentNull");
         throw;
     }
     PexGoal.Reached("Normal");
 }
Example #6
0
 public void MaxValueDigitsLessThanZeroPUT(int exponentVal)
 {
     PexAssume.IsFalse(exponentVal > 0);
     if (exponentVal < 0)
     {
         try
         {
             Numbers.MaxValue(Base.Binary, exponentVal);
         }
         catch (ArgumentOutOfRangeException ex)
         {
             PexGoal.Reached();
         }
     }
     else
     {
         PexAssert.AreEqual(0, Numbers.MaxValue(Base.Binary, exponentVal));
     }
 }
Example #7
0
 public void ToHexPUT(int actual)
 {
     if (actual < 0)
     {
         try
         {
             actual.ToHex();
         }
         catch (ArgumentOutOfRangeException ex)
         {
             PexGoal.Reached();
         }
     }
     else
     {
         string hexValue = actual.ToString("X");
         PexAssert.AreEqual(hexValue, actual.ToHex());
     }
 }
Example #8
0
 public void ToOctalNegativeIntPUT(int actual)
 {
     if (actual < 0)
     {
         try
         {
             actual.ToOctal();
         }
         catch (ArgumentOutOfRangeException ex)
         {
             PexGoal.Reached();
         }
     }
     else
     {
         int expected = Convert.ToInt32(Convert.ToString(actual, 8));
         PexAssert.AreEqual(expected, actual.ToOctal());
     }
 }
Example #9
0
 public void ToBaseTwoNegativeIntPUT(int actual)
 {
     if (actual < 0)
     {
         try
         {
             actual.ToBinary();
         }
         catch (ArgumentOutOfRangeException ex)
         {
             PexGoal.Reached();
         }
     }
     else
     {
         int result   = actual.ToBinary();
         int expected = Convert.ToInt32(Convert.ToString(actual, 2));
         PexAssert.AreEqual(expected, result);
     }
 }
Example #10
0
        /// Summary
        /// Time: 6 min 23 sec
        /// Pattern: Commutative diagram, Allowed Exception, Reachability
        /// Generalizes two unit tests PeekTest and PeekNoItemsInTheQueueTest into one PUT
        public void PeekTest(int[] newElements)
        {
            try
            {
                PriorityQueue <int> actual = new PriorityQueue <int>(newElements);

                //get the minimum element
                int minVal = Int32.MaxValue;
                for (int i = 0; i < newElements.Length; i++)
                {
                    minVal = minVal > newElements[i] ? newElements[i] : minVal;
                }

                PexAssert.AreEqual(minVal, actual.Peek());
                PexGoal.Reached("normal");
            }
            catch (InvalidOperationException)
            {
                PexGoal.Reached("exception");
                throw;
            }
        }