123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using System;
- using LR4;
- namespace Test
- {
- [TestClass]
- public class UnitTest1
- {
- //тесты низкой сложности
- [TestMethod]
- public void SumTest()
- {
- double result = MainWindow.Plus(10, 7);
- Assert.AreEqual(17, result);
- }
- [TestMethod]
- public void DiffTest()
- {
- double result = MainWindow.Minus(10, 7);
- Assert.AreNotEqual(417, result);
- }
- [TestMethod]
- public void MultTest()
- {
- double result = MainWindow.Plus(10, 7);
- bool flag = true;
- if (result == 17)
- {
- flag = true;
- }
- else
- {
- flag = false;
- }
- Assert.IsTrue(flag);
- }
- [TestMethod]
- public void DivTest()
- {
- double result = MainWindow.Plus(10, 7);
- bool flag = false;
- if (result == 11)
- {
- flag = false;
- }
- else
- {
- flag = true;
- }
- Assert.IsTrue(flag);
- }
- [TestMethod]
- public void TruePlusMultiplyTest()
- {
- double result = MainWindow.Plus(10, 5);
- bool flag1 = true;
- if (result == 11)
- {
- flag1 = true;
- }
- else
- {
- flag1 = false;
- }
- bool flag2 = true;
- if (result == 17)
- {
- flag2 = true;
- }
- else
- {
- flag2 = false;
- }
- Assert.AreEqual(flag1, flag2);
- }
- [TestMethod]
- public void PowerTest()
- {
- double result = MainWindow.Power(4, 5);
- Assert.IsInstanceOfType(result, typeof(double));
- }
- [TestMethod]
- public void RootTest()
- {
- double result = MainWindow.Root(2);
- Assert.IsNotInstanceOfType(result, typeof(int));
- }
- [TestMethod]
- public void PercentTest()
- {
- double result = MainWindow.Percent(1, 5);
- Assert.IsNotNull(result);
- }
- [TestMethod]
- public void Log()
- {
- double result = MainWindow.Percent(50, 10);
- Assert.AreEqual(5, result);
- }
-
- [TestMethod]
- public void DivMultTest()
- {
- double result1 = MainWindow.Multiply(7, 4);
- double result2 = MainWindow.Divide(31, 1);
- Assert.AreNotEqual(result2, result1);
- }
- //тесты высокой сложности
- [TestMethod]
- public void ExPlusMethod()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Plus(Convert.ToInt32("a"), 6)));
- }
- [TestMethod]
- public void ExMinusMethod()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Minus(Convert.ToInt32("a"), 5)));
- }
- [TestMethod]
- public void ExDivMethod()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Ctg(Convert.ToInt32("a"), 5)));
- }
- [TestMethod]
- public void ExRootMethod()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Log(Convert.ToInt32("a"), 5)));
- }
- [TestMethod]
- public void ExSinMethod()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Sin(Convert.ToInt32("a"))));
- }
- }
- }
|