using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using WSUniversalLib; namespace UnitTestorWSULib { [TestClass] public class UnitTest1 { #region Простые [TestMethod] public void ResultEqualCorrect() { Assert.AreEqual(114147,Calculation.GetQuantityForProduct(3,1,15,20,45)); } [TestMethod] public void ResultEqualNotCorrect() { Assert.AreNotEqual(114148, Calculation.GetQuantityForProduct(3, 1, 20, 21, 46)); } [TestMethod] public void ResultIsNotNull() { Assert.IsNotNull(Calculation.GetQuantityForProduct(3, 1, 15, 45, 13)); } [TestMethod] public void BadResultProductEqualCorrect() { Assert.AreEqual(-1, Calculation.GetQuantityForProduct(4, 1, 20, 21, 46)); } [TestMethod] public void BadResultMaterialEqualCorrect() { Assert.AreEqual(-1, Calculation.GetQuantityForProduct(3, 5, 20, 21, 46)); } [TestMethod] public void IsCorrectType() { Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(3, 5, 20, 21, 46), typeof(int)); } [TestMethod] public void IsIncorrectType() { Assert.IsNotInstanceOfType(Calculation.GetQuantityForProduct(3, 5, 20, 21, 46), typeof(double)); } [TestMethod] public void ResultNotEqualIncorrect() { Assert.AreNotEqual(-1, Calculation.GetQuantityForProduct(3, 1, 20, 21, 46)); } [TestMethod] public void ResultEqualIncorrect() { Assert.AreEqual(-1, Calculation.GetQuantityForProduct(4, 4, 20, 21, 46)); } [TestMethod] public void BadResultIsType() { Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(4, 4, 20, 21, 46), typeof(int)); } #endregion #region Сложные [TestMethod] public void ThrowThirdArgException() { Assert.ThrowsException(()=>Calculation.GetQuantityForProduct(1, 1, -1, 1, 1)); } [TestMethod] public void ThrowFourthArgException() { Assert.ThrowsException(() => Calculation.GetQuantityForProduct(1, 1, 1, -1, 1)); } [TestMethod] public void ThrowFifthArgException() { Assert.ThrowsException(() => Calculation.GetQuantityForProduct(1, 1, 1, 1, -11)); } [TestMethod] public void ThrowTwoArgException() { Assert.ThrowsException(() => Calculation.GetQuantityForProduct(1, 1, 1, -1, -11)); } [TestMethod] public void ThrowThreeArgException() { Assert.ThrowsException(() => Calculation.GetQuantityForProduct(1, 1, -1, -1, -11)); } #endregion } }