UnitTest1.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using Calculator;
  4. namespace UnitTests
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. [TestMethod]
  10. public void TestMethodAreEqual_true()
  11. {
  12. double exepted = 15;
  13. double real = MainWindow.Summ(7,8);
  14. Assert.AreEqual(exepted, real);
  15. }
  16. [TestMethod]
  17. public void TestMethodAreNotEqual_true()
  18. {
  19. double exepted = 0;
  20. double real = MainWindow.Root(4);
  21. Assert.AreNotEqual(exepted, real);
  22. }
  23. [TestMethod]
  24. public void TestMethodIsTrue_true()
  25. {
  26. double exepted = 3125;
  27. double real = MainWindow.Degree(5, 5);
  28. Assert.IsTrue(exepted == real);
  29. }
  30. [TestMethod]
  31. public void TestMethodIsFalse_false()
  32. {
  33. double exepted = 5;
  34. double real = MainWindow.Subtraction(1, 5);
  35. Assert.IsFalse(exepted == real);
  36. }
  37. [TestMethod]
  38. public void TestMethodIsType_trueDouble()
  39. {
  40. double excepted = MainWindow.Multiplication(2,1);
  41. Assert.IsInstanceOfType(excepted, typeof(double));
  42. }
  43. [TestMethod]
  44. public void TestMethodIsType_falseInt()
  45. {
  46. double excepted = MainWindow.Divide(5, 5);
  47. Assert.IsNotInstanceOfType(excepted, typeof(int));
  48. }
  49. [TestMethod]
  50. public void TestMethodIsNotNull_true()
  51. {
  52. double excepted = MainWindow.Procent(21, 1);
  53. Assert.IsNotNull(excepted);
  54. }
  55. [TestMethod]
  56. public void TestMethodSinAreNotEquals_true()
  57. {
  58. double excepted = 1;
  59. double real = MainWindow.Sin(20);
  60. Assert.AreNotEqual(excepted, real);
  61. }
  62. [TestMethod]
  63. public void TestMethodCtgIsTrue_true()
  64. {
  65. double exepted = 0;
  66. double real = MainWindow.Ctg(1.5708);
  67. Assert.IsFalse(exepted == real);
  68. }
  69. [TestMethod]
  70. public void TestMethodLogAreEqual_true()
  71. {
  72. double exepted = 0;
  73. double real = MainWindow.Log(1);
  74. Assert.AreEqual(exepted, real);
  75. }
  76. [TestMethod]
  77. public void TestMethodThrowExceptionNull()
  78. {
  79. Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Summ(Convert.ToDouble(null), 5)));
  80. }
  81. [TestMethod]
  82. public void TestMethodThrowExceptionBigData()
  83. {
  84. Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Subtraction(Convert.ToDouble(3000000000), 5)));
  85. }
  86. [TestMethod]
  87. public void TestMethodThrowExceptionSymbols()
  88. {
  89. Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Multiplication(Convert.ToDouble("hello"), 5)));
  90. }
  91. [TestMethod]
  92. public void TestMethodThrowExceptionDivideOnZero()
  93. {
  94. Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Divide(23, 0)));
  95. }
  96. [TestMethod]
  97. public void TestMethodThrowExceptionSqrtZero()
  98. {
  99. Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Root(0)));
  100. }
  101. }
  102. }