|
@@ -0,0 +1,124 @@
|
|
|
|
+using System;
|
|
|
|
+using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
+using WSUniversalLib;
|
|
|
|
+
|
|
|
|
+namespace TestWSUniversalLib
|
|
|
|
+{
|
|
|
|
+ [TestClass]
|
|
|
|
+ public class UnitTest
|
|
|
|
+ {
|
|
|
|
+ Calculation calc = new Calculation();
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_TestCalculationEquale()
|
|
|
|
+ {
|
|
|
|
+ int exp = 114148;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(3, 1, 15, 20, 45);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_AreNotSame()
|
|
|
|
+ {
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, 3, 4, 5);
|
|
|
|
+ var exp = calc.GetQuantityForProduct(1, 2, 3, 4, 5);
|
|
|
|
+ Assert.AreNotSame(ans, exp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NegativeHeight()
|
|
|
|
+ {
|
|
|
|
+ Assert.IsNotNull(calc.GetQuantityForProduct(1, 2, 3, 4, 5));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_TypeOfFloat()
|
|
|
|
+ {
|
|
|
|
+ Assert.IsNotInstanceOfType(calc.GetQuantityForProduct(1, 2, 3, 4, 5), typeof(float));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_TypeOfInt()
|
|
|
|
+ {
|
|
|
|
+ Assert.IsInstanceOfType(calc.GetQuantityForProduct(1, 2, 3, 4, 5), typeof(int));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void GetQuantityForProduct_NullHeight()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, 3, 4, Convert.ToInt32(null));
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NotExistentProductType()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(10, 2, 3, 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NotExistentMaterialType()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 20, 3, 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NegativeCount()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, -3, 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NegativeWidth()
|
|
|
|
+ {
|
|
|
|
+ var exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, 3, -4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NegativeLenght()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, 3, 4, -5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NullProductType()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(Convert.ToInt32(null), 2, 3, 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NullMaterialType()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, Convert.ToInt32(null), 3, 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NullCount()
|
|
|
|
+ {
|
|
|
|
+ int exp = 0;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, Convert.ToInt32(null), 4, 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void GetQuantityForProduct_NullWidht()
|
|
|
|
+ {
|
|
|
|
+ int exp = -1;
|
|
|
|
+ var ans = calc.GetQuantityForProduct(1, 2, 3, Convert.ToInt32(null), 5);
|
|
|
|
+ Assert.AreEqual(exp, ans);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|