stkirov

UnitTestForTask4

Jan 16th, 2013
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3.  
  4. namespace UnitTestForTask4
  5. {
  6.     [TestClass]
  7.     public class TestTask4
  8.     {
  9.         static decimal maxValue = decimal.MaxValue;
  10.         static decimal minValue = decimal.MinValue;
  11.  
  12.         [TestMethod]
  13.         public void TestWithMinValue()
  14.         {
  15.             //data to check
  16.             decimal[] array = { maxValue, minValue, 7, minValue, 2 };
  17.  
  18.             //add test data
  19.             NumberInArrayWithTests.numberToCheck = minValue;
  20.             NumberInArrayWithTests.CountAppearances(array);
  21.  
  22.             //assert
  23.             Assert.AreEqual(2, NumberInArrayWithTests.counter);
  24.             //we  null the counter in order to reset the counter in the original class, because it's static and currently set to 2.
  25.             NumberInArrayWithTests.counter = 0;
  26.         }
  27.  
  28.         [TestMethod]
  29.         public void TestWithMaxValue()
  30.         {
  31.             //data to check
  32.             decimal[] array = { 17, 5212, 17, 5212, maxValue, maxValue, maxValue, 0 };
  33.  
  34.             //add test data
  35.             NumberInArrayWithTests.numberToCheck = maxValue;
  36.             NumberInArrayWithTests.CountAppearances(array);
  37.  
  38.             //assert
  39.             Assert.AreEqual(3, NumberInArrayWithTests.counter);
  40.         }
  41.  
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment