Exemple #1
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));
        }
Exemple #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));
        }
Exemple #3
0
 public int NotEmptyTest(NotEmptyModel model)
 {
     return(100);
 }