using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using Calculator; namespace UnitTests { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethodAreEqual_true() { double exepted = 15; double real = MainWindow.Summ(7,8); Assert.AreEqual(exepted, real); } [TestMethod] public void TestMethodAreNotEqual_true() { double exepted = 0; double real = MainWindow.Root(4); Assert.AreNotEqual(exepted, real); } [TestMethod] public void TestMethodIsTrue_true() { double exepted = 3125; double real = MainWindow.Degree(5, 5); Assert.IsTrue(exepted == real); } [TestMethod] public void TestMethodIsFalse_false() { double exepted = 5; double real = MainWindow.Subtraction(1, 5); Assert.IsFalse(exepted == real); } [TestMethod] public void TestMethodIsType_trueDouble() { double excepted = MainWindow.Multiplication(2,1); Assert.IsInstanceOfType(excepted, typeof(double)); } [TestMethod] public void TestMethodIsType_falseInt() { double excepted = MainWindow.Divide(5, 5); Assert.IsNotInstanceOfType(excepted, typeof(int)); } [TestMethod] public void TestMethodIsNotNull_true() { double excepted = MainWindow.Procent(21, 1); Assert.IsNotNull(excepted); } [TestMethod] public void TestMethodSinAreNotEquals_true() { double excepted = 1; double real = MainWindow.Sin(20); Assert.AreNotEqual(excepted, real); } [TestMethod] public void TestMethodCtgIsTrue_true() { double exepted = 0; double real = MainWindow.Ctg(1.5708); Assert.IsFalse(exepted == real); } [TestMethod] public void TestMethodLogAreEqual_true() { double exepted = 0; double real = MainWindow.Log(1); Assert.AreEqual(exepted, real); } [TestMethod] public void TestMethodThrowExceptionNull() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Summ(Convert.ToDouble(null), 5))); } [TestMethod] public void TestMethodThrowExceptionBigData() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Subtraction(Convert.ToDouble(3000000000), 5))); } [TestMethod] public void TestMethodThrowExceptionSymbols() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Multiplication(Convert.ToDouble("hello"), 5))); } [TestMethod] public void TestMethodThrowExceptionDivideOnZero() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Divide(23, 0))); } [TestMethod] public void TestMethodThrowExceptionSqrtZero() { Assert.ThrowsException(() => Assert.ThrowsException(() => MainWindow.Root(0))); } } }