123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Summ(Convert.ToDouble(null), 5)));
- }
- [TestMethod]
- public void TestMethodThrowExceptionBigData()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Subtraction(Convert.ToDouble(3000000000), 5)));
- }
- [TestMethod]
- public void TestMethodThrowExceptionSymbols()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Multiplication(Convert.ToDouble("hello"), 5)));
- }
- [TestMethod]
- public void TestMethodThrowExceptionDivideOnZero()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Divide(23, 0)));
- }
- [TestMethod]
- public void TestMethodThrowExceptionSqrtZero()
- {
- Assert.ThrowsException<AssertFailedException>(() => Assert.ThrowsException<SystemException>(() => MainWindow.Root(0)));
- }
- }
- }
|