Ver código fonte

Сделаны простые тесты

Barsik Kato 2 anos atrás
pai
commit
8a7dc55e17

+ 23 - 1
Session2ModuleTest/UnitTest1.cs

@@ -7,9 +7,31 @@ namespace Session2ModuleTest
     [TestClass]
     public class UnitTest1
     {
+        Calculation calc = new Calculation();
         [TestMethod]
-        public void TestMethod1()
+        public void GetPriorityForAgent_NonExistentAgentType()
         {
+            Assert.AreEqual(-1, calc.GetPriorityForAgent(0, 25, 2));
+        }
+        [TestMethod]
+        public void GetPriorityForAgent_ImpossibleAgentAge()
+        {
+            Assert.AreEqual(-1, calc.GetPriorityForAgent(2, -1, 2));
+        }
+        [TestMethod]
+        public void GetPriorityForAgent_ImpossibleAgentExperience()
+        {
+            Assert.AreEqual(-1, calc.GetPriorityForAgent(2, 25, -1));
+        }
+        [TestMethod]
+        public void GetPriorityForAgent_ExperienceBiggerThanAge()
+        {
+            Assert.AreEqual(-1, calc.GetPriorityForAgent(2, 24, 25));
+        }
+        [TestMethod]
+        public void GetPriorityForAgent_EasyCalculation()
+        {
+            Assert.AreEqual(5, calc.GetPriorityForAgent(2, 23, 1.5f));
         }
     }
 }

+ 2 - 2
WSUniversalLib/Class1.cs

@@ -11,7 +11,7 @@ namespace WSUniversalLib
         public int GetPriorityForAgent(int agentType, float age, float experience)
         {
             float x;
-            if (age < 0 || experience < 0)
+            if (age < 0 || experience < 0 || experience > age)
                 return -1;
             switch(agentType)
             {
@@ -56,7 +56,7 @@ namespace WSUniversalLib
                         return -1;
                 }
             }
-            return (int)x;
+            return (int)(x * experience);
         }
     }
 }

BIN
WSUniversalLib/WSUniversalLib.dll