Exemplo n.º 1
0
        public void SizeTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                SizeModel model = new SizeModel
                {
                    StrField  = "12345",
                    IntFields = new List <int>()
                    {
                        1, 2, 3, 4
                    },
                };
                res = new TestLogic().SizeTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                SizeModel model = new SizeModel
                {
                    StrField  = "123",
                    IntFields = new List <int>()
                    {
                        1, 2, 3, 4
                    },
                };
                res = new TestLogic().SizeTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            /*************************************************************/

            errMsg = string.Empty;
            res    = 0;

            try
            {
                SizeModel model = new SizeModel
                {
                    StrField  = "12345",
                    IntFields = new List <int>()
                    {
                        1, 2, 3, 4
                    },
                };
                res = new TestLogic().SizeTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                SizeModel model = new SizeModel
                {
                    StrField  = "12345",
                    IntFields = new List <int>()
                    {
                        1, 2
                    },
                };
                res = new TestLogic().SizeTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
Exemplo n.º 2
0
        public void NotEmptyTest1()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                NotEmptyModel1 model1 = new NotEmptyModel1()
                {
                    //ArrayFields = new ArrayList(),
                    BitArrayFields = new BitArray(1),
                    //DicFields = new Dictionary<int, string>(),
                    HashSetFields = new HashSet <int>(),
                    //HashtableFields = new Hashtable(),
                    HybridDictionaryFields = new HybridDictionary(),
                    //LinkedListFields = new LinkedList<string>(),
                    ListDictionaryFields = new ListDictionary(),
                    //QueueFields = new Queue(2),
                    //SortedListFields = new SortedList(),
                    //SortedListFields1 = new SortedList<int, string>(),
                    SortedSetFields = new SortedSet <int>(),
                    //StackFields = new Stack<int>()
                };

                //model1.DicFields.Add(1, "2");
                //model1.ArrayFields.Add(1);
                //model1.ArrayFields.Add(2);
                //model1.QueueFields.Enqueue(1);
                //model1.LinkedListFields.AddFirst("1");
                //model1.HashtableFields.Add("1",1);
                model1.HashSetFields.Add(1);
                model1.HybridDictionaryFields.Add(1, "2");
                model1.ListDictionaryFields.Add("1", 1);
                //model1.SortedListFields.Add(1,"1");
                //model1.SortedListFields1.Add(1,"2");
                model1.SortedSetFields.Add(1);
                //model1.StackFields.Push(1);
                model1.ArrayFields  = new[] { 1, 2 };
                model1.ArrayFields2 = null;


                res = new TestLogic().NotEmptyTest1(model1);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                NotEmptyModel model = new NotEmptyModel
                {
                    StrField  = " ",
                    StrFields = new List <string>(),
                };
                model.ArrayFields = null;
                res = new TestLogic().NotEmptyTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
Exemplo n.º 3
0
        public void NotEmptyTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                NotEmptyModel model = new NotEmptyModel
                {
                    StrField  = " ",
                    StrFields = new List <string>()
                    {
                        " "
                    },
                    StrFieldList = new List <string>()
                    {
                        " "
                    },
                };
                res = new TestLogic().NotEmptyTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                NotEmptyModel model = new NotEmptyModel
                {
                    StrField  = "",
                    StrFields = new List <string>()
                    {
                        " "
                    },
                    StrFieldList = new List <string>()
                    {
                    },
                };
                res = new TestLogic().NotEmptyTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                NotEmptyModel model = new NotEmptyModel
                {
                    StrField     = " ",
                    StrFields    = new List <string>(),
                    StrFieldList = new List <string>()
                    {
                        " "
                    },
                };
                res = new TestLogic().NotEmptyTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
Exemplo n.º 4
0
        public void MaxTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 1f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 100.01f,
                    FloatField1 = 1f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            /*********************************************************************************/

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 100.01f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 1000.01f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
Exemplo n.º 5
0
        public void FutureTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                FutureModel model = new FutureModel
                {
                    DatetimeField  = DateTime.Now.AddMinutes(10),
                    DatetimeField1 = DateTime.MaxValue,
                };
                res = new TestLogic().FutureTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                FutureModel model = new FutureModel
                {
                    DatetimeField  = new DateTime(2019, 10, 05),
                    DatetimeField1 = DateTime.MaxValue,
                };
                res = new TestLogic().FutureTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            /**********************************************/

            errMsg = string.Empty;
            res    = 0;

            try
            {
                FutureModel model = new FutureModel
                {
                    DatetimeField  = DateTime.MaxValue,
                    DatetimeField1 = new DateTime(2019, 09, 01),
                };
                res = new TestLogic().FutureTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                FutureModel model = new FutureModel
                {
                    DatetimeField  = DateTime.MaxValue,
                    DatetimeField1 = new DateTime(2019, 01, 05),
                };
                res = new TestLogic().FutureTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
Exemplo n.º 6
0
        public void DigitsTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                DigitsModel model = new DigitsModel
                {
                    DecimalField = 10.01m,
                };

                res = new TestLogic().DigitsTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }

            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;
            try
            {
                DigitsModel model = new DigitsModel
                {
                    DecimalField = 1002.0102m,
                };

                res = new TestLogic().DigitsTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }

            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            /****************************************************/

            errMsg = string.Empty;
            res    = 0;

            try
            {
                DigitsModel model = new DigitsModel
                {
                    DecimalField = 1.1m,
                };

                res = new TestLogic().DigitsTest2(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }

            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;
            try
            {
                DigitsModel model = new DigitsModel
                {
                    DecimalField = 100.002m,
                };

                res = new TestLogic().DigitsTest2(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }

            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }