Esempio n. 1
0
        public void randomTestSIMDEN()
        {
            System.Random RandNum  = new System.Random();
            SIMDEN        instance = new SIMDEN();
            int           SoilCode;
            int           FarmType;
            decimal       FertiliserN;
            decimal       ManureNincorp;
            decimal       ManureNspread;
            decimal       NFixation;



            for (int i = 0; i < 10000; i++)
            {
                SoilCode      = RandNum.Next(1, 12);
                FarmType      = RandNum.Next(1, 3);
                FertiliserN   = (decimal)RandNum.NextDouble() * (250);
                ManureNincorp = (decimal)RandNum.NextDouble() * (350);
                ManureNspread = (decimal)RandNum.NextDouble() * (350);
                NFixation     = (decimal)RandNum.NextDouble() * (200);
                instance      = new SIMDEN();
                instance.init(SoilCode, FarmType, FertiliserN, ManureNincorp, ManureNspread, NFixation);
            }
        }
Esempio n. 2
0
        public void systematicTestSIMDEN()
        {
            SIMDEN instance = new SIMDEN();

            for (int i = 1; i <= 12; i++)
            {
                instance.init(i, 2, 125m, 175m, 175m, 100m);
            }
            instance = new SIMDEN();
            for (int i = 1; i <= 3; i++)
            {
                instance.init(6, i, 125m, 175m, 175m, 100m);
            }
            instance = new SIMDEN();
            decimal FertiliserN = 0;

            for (int i = 0; i <= 100; i = i + 1)
            {
                instance.init(6, 2, FertiliserN, 175m, 175m, 100m);
                FertiliserN += 2.5m;
            }
            instance = new SIMDEN();

            for (int i = 0; i <= 300; i = i + 3)
            {
                instance.init(6, 2, 125m, i, 175m, 100m);
            }
            instance = new SIMDEN();
            for (int i = 0; i <= 300; i = i + 3)
            {
                instance.init(6, 2, 125m, 175m, i, 100m);
            }
            instance = new SIMDEN();
            for (int i = 0; i <= 100; i += 1)
            {
                instance.init(6, 2, 125m, 175m, 175m, i);
            }
        }
Esempio n. 3
0
        public void SIMDENFarmType3()
        {
            SIMDEN target;

            target = new SIMDEN();  target.init(1, 3, 1, 1, 1, 1);
            decimal actual   = target.getDenitrification();
            decimal expected = 0.892m;

            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(1, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 0.8m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(2, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 1.94m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(2, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 1.8m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(3, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 3.488m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(3, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 3.3m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(4, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 6.884m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(4, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 6.6m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(5, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 11.108m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(5, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 10.8m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(6, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 14.756m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(6, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 14.4m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(7, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 18.804m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(7, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 18.4m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(10, 3, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 27.452m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(10, 3, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 27m;
            Assert.AreEqual(actual, expected);
        }
Esempio n. 4
0
        public void SIMDENExeption()
        {
            SIMDEN target = new SIMDEN();


            int  returnValue;
            bool expetion = false;

            try
            {
                returnValue = target.init(0, 1, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: SoilType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(-900, 1, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: SoilType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 0, 0, 1, 2);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(6, 1, 0, 0, 1, 2);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(12, 1, 0, 0, 1, 2);
            Assert.AreEqual(0, returnValue);
            expetion = false;
            try
            {
                returnValue = target.init(13, 1, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: SoilType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(18, 1, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: SoilType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, -900, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FarmType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 0, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FarmType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 0, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 2, 0, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 3, 0, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            expetion = false;
            try
            {
                returnValue = target.init(1, 4, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FarmType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 900, 0, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FarmType is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, -10, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FertiliserN is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, -1, 0, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: FertiliserN is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 0, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 1, 10, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, -10, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: ManureNincorp is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, -1, 1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: ManureNincorp is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 2, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 1, 2, 10, 1, 0);
            Assert.AreEqual(0, returnValue);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, 0, -1, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: ManureNspread is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, 0, -10, 2);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: ManureNspread is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 0, 0, 0, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 1, 0, 0, 900, 0);
            Assert.AreEqual(0, returnValue);

            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, 0, 1, -10);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: NFixation is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            expetion = false;
            try
            {
                returnValue = target.init(1, 1, 0, 0, 1, -1);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN: NFixation is not valid\" and type 2"))
                {
                    expetion = true;
                }
            }

            Assert.IsTrue(expetion);
            returnValue = target.init(1, 1, 0, 0, 1, 0);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 1, 0, 0, 1, 10);
            Assert.AreEqual(0, returnValue);
            returnValue = target.init(1, 1, 0, 0, 1, 0);
            if (returnValue == -1)
            {
                Assert.Fail();
            }
        }
Esempio n. 5
0
        public void SIMDENFarmType1()
        {
            bool   used   = false;
            SIMDEN target = new SIMDEN();

            try
            {
                target.getDenitrification();
            }
            catch (Exception e)
            {
                string df = e.Message;
                if (e.Message.Equals("Message: Cannot handle exeption with name \"SIMDEN:Has not been init before receiving output\" and type 1"))
                {
                    used = true;
                }
            }
            Assert.IsTrue(used);
            target = new SIMDEN();  target.init(1, 1, 1, 1, 1, 1);
            decimal actual   = target.getDenitrification();
            decimal expected = 0.068m;

            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(1, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 0.0m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(2, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 0.592m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(2, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 0.5m;
            Assert.AreEqual(actual, expected);



            target   = new SIMDEN();  target.init(3, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 1.54m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(3, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 1.4m;
            Assert.AreEqual(actual, expected);



            Assert.AreEqual(actual, expected);
            target   = new SIMDEN();  target.init(4, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 2.988m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(4, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 2.8m;
            Assert.AreEqual(actual, expected);


            target   = new SIMDEN();  target.init(5, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 5.012m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(5, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 4.8m;


            target   = new SIMDEN();  target.init(6, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 7.56m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(6, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 7.3m;


            target   = new SIMDEN();  target.init(7, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 10.508m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(7, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 10.2m;


            target   = new SIMDEN();  target.init(10, 1, 1, 1, 1, 1);
            actual   = target.getDenitrification();
            expected = 14.356m;
            Assert.AreEqual(actual, expected);

            target   = new SIMDEN();  target.init(10, 1, 0, 0, 0, 0);
            actual   = target.getDenitrification();
            expected = 14m;
            Assert.AreEqual(actual, expected);
        }