1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using System;
- using WSUniversalLib;
- namespace UnitTestProject1
- {
- [TestClass]
- public class UnitTest1
- {
- [TestMethod]
- public void GetQuantityForProduct_AreEqual_CheckData()
- {
- Assert.AreEqual(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), 114147);
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckError_IsTrue()
- {
- bool res = true;
- if(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45) == -1)
- {
- res = false;
- }
- Assert.IsTrue(res);
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckError_IsFalse()
- {
- bool res = true;
- if (Calculation.GetQuantityForProduct(5, 1, 15, 20, 45) == -1)
- {
- res = false;
- }
- Assert.IsFalse(res);
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckData_IsNotNull()
- {
- Assert.IsNotNull(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45));
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckData_ReturnTypeIsInt()
- {
- Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), typeof(int));
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckData_ReturnTypeIsNotInt()
- {
- Assert.IsNotInstanceOfType(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), typeof(double));
- }
- [TestMethod]
- public void GetQuantityForProduct_AreEqualNotEqual()
- {
- Assert.AreNotEqual(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), 777);
- }
- [TestMethod]
- public void GetQuantityForProduct_CheckData_InvalidProdType()//Тут начинаются сложные тесты
- {
- Assert.AreEqual(Calculation.GetQuantityForProduct(5, 1, 15, 20, 45), -1);
- }
- [TestMethod]
- public void GetQuantityForProduct_ThrowException_InvalidCount()
- {
- Assert.ThrowsException<System.Exception>(() => Calculation.GetQuantityForProduct(3, 1, 0, 20, 45));
- }
- [TestMethod]
- public void GetQuantityForProduct_ThrowException_InvalidWidth()
- {
- Assert.ThrowsException<System.Exception>(() => Calculation.GetQuantityForProduct(3, 1, 15, 0, 45));
- }
- [TestMethod]
- public void GetQuantityForProduct_ThrowException_InvalidLength()
- {
- Assert.ThrowsException<System.Exception>(() => Calculation.GetQuantityForProduct(3, 1, 15, 20, 0));
- }
- }
- }
|