UnitTest1.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using Calculation;
  4. namespace UnitTestProject1
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. Calculator cs;
  10. [TestMethod]
  11. public void TestMethod1()
  12. {
  13. cs = new Calculator();
  14. Assert.AreEqual(cs.Calc(13M, 14), cs.Calc(13M, 15));
  15. }
  16. [TestMethod]
  17. public void TestMethod2()
  18. {
  19. cs = new Calculator();
  20. Assert.AreEqual(cs.Calc(0M, 0), cs.Calc(0M, 2));
  21. }
  22. [TestMethod]
  23. public void TestMethod3()
  24. {
  25. cs = new Calculator();
  26. Assert.AreEqual(0, cs.Calc(0M, 0));
  27. }
  28. [TestMethod]
  29. public void TestMethod4()
  30. {
  31. cs = new Calculator();
  32. Assert.AreEqual(0, cs.Calc(122.21M, Convert.ToInt32(10 * 0.2)));
  33. }
  34. [TestMethod]
  35. public void TestMethod5()
  36. {
  37. cs = new Calculator();
  38. int count = Convert.ToInt32(10 * 0.2);
  39. decimal price = 122.21M;
  40. Assert.AreEqual(1, cs.Calc(price * 5, count));
  41. }
  42. [TestMethod]
  43. public void TestMethod6()
  44. {
  45. cs = new Calculator();
  46. Assert.AreEqual(0, cs.Calc(0M, Convert.ToInt32(10 * 0.5)));
  47. }
  48. [TestMethod]
  49. public void TestMethod7()
  50. {
  51. cs = new Calculator();
  52. Assert.AreEqual(0, cs.Calc(12.5M, Convert.ToInt32(10 * 0.2)));
  53. }
  54. [TestMethod]
  55. public void TestMethod8()
  56. {
  57. cs = new Calculator();
  58. Assert.AreEqual(15, cs.Calc(0.3M, 10));
  59. }
  60. [TestMethod]
  61. public void TestMethod9()
  62. {
  63. cs = new Calculator();
  64. Assert.AreEqual(16, cs.Calc(750, 17));
  65. }
  66. [TestMethod]
  67. public void TestMethod10()
  68. {
  69. cs = new Calculator();
  70. Assert.AreEqual(0, cs.Calc(750, 0));
  71. }
  72. }
  73. }