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(() => Assert.ThrowsException(() => MainWindow.Plus(Convert.ToInt32("a"), 6))); } [TestMethod] public void ExMinusMethod() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Minus(Convert.ToInt32("a"), 5))); } [TestMethod] public void ExDivMethod() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Ctg(Convert.ToInt32("a"), 5))); } [TestMethod] public void ExRootMethod() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Log(Convert.ToInt32("a"), 5))); } [TestMethod] public void ExSinMethod() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Sin(Convert.ToInt32("a")))); } } }