UnitTest1.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Library;
  2. namespace TestMethodsLibrary.Test
  3. {
  4. [TestClass]
  5. public class UnitTest1
  6. {
  7. [TestMethod]
  8. public void TestMethod_CreateStack_ExeptedStack3Values_ResultStack3Values()
  9. {
  10. Stack<double> exepted = new Stack<double>();
  11. exepted.Push(-1);
  12. exepted.Push(-2);
  13. exepted.Push(-3);
  14. Stack<double> result = new Stack<double>();
  15. MethodExamTask methodExamTask = new MethodExamTask();
  16. result = methodExamTask.AddValueInStack(-1, result);
  17. result = methodExamTask.AddValueInStack(-2, result);
  18. result = methodExamTask.AddValueInStack(-3, result);
  19. CollectionAssert.AreEquivalent(exepted, result);
  20. }
  21. [TestMethod]
  22. public void TestMethod_CountOtricNumInStack_Exepted2_Result2()
  23. {
  24. int exepted = 2;
  25. MethodExamTask methodExamTask = new MethodExamTask();
  26. Stack<double> stackResult = new Stack<double>();
  27. stackResult = methodExamTask.AddValueInStack(-1, stackResult);
  28. stackResult = methodExamTask.AddValueInStack(-2, stackResult);
  29. stackResult = methodExamTask.AddValueInStack(5, stackResult);
  30. int result = methodExamTask.CountOtricNumInStack(stackResult);
  31. Assert.AreEqual(exepted, result);
  32. }
  33. [TestMethod]
  34. public void TestMethod_CountSumOricNumInStack_ExeptedMinus11_ResultMinus11()
  35. {
  36. int exepted = -11;
  37. MethodExamTask methodExamTask = new MethodExamTask();
  38. Stack<double> stackResult = new Stack<double>();
  39. stackResult = methodExamTask.AddValueInStack(-5, stackResult);
  40. stackResult = methodExamTask.AddValueInStack(-6, stackResult);
  41. stackResult = methodExamTask.AddValueInStack(43, stackResult);
  42. double result = methodExamTask.CountSumOricNumInStack(stackResult);
  43. Assert.AreEqual(exepted, result);
  44. }
  45. }
  46. }