예제 #1
0
        public object FindBy(string criteria, params int[] value)
        {
            CustomRepository <int> repo = new CustomRepository <int>();

            repo.FindByGlossary(value[0], criteria);
            return(CustomerAccess.GetData());
        }
예제 #2
0
        public override object Execute()
        {
            foreach (NewCriteria <T> criteria in _criterias)
            {
                if (criteria != null)
                {
                    switch (criteria.Criteria)
                    {
                    case Utilites.QueryCriteria.ID:
                        CustomerAccess.GetCustomersByID(Convert.ToInt32(criteria.First));
                        break;

                    case Utilites.QueryCriteria.Bithday:
                        if (criteria.Predicate == "Between")
                        {
                            CustomerAccess.GetCustomersByBirthdayBetween(Convert.ToDateTime(criteria.First),
                                                                         Convert.ToDateTime(criteria.Second));
                        }
                        else
                        {
                            CustomerAccess.GetCustomersByBirthOfDay(Convert.ToDateTime(criteria.First),
                                                                    criteria.Predicate);
                        }
                        break;

                    default:
                        CustomerAccess.GetDataByCriteria(criteria.Criteria,
                                                         criteria.Values.Cast <object>().ToArray(), criteria.Predicate);
                        break;
                    }
                }
            }
            return(CustomerAccess.GetData());
        }
예제 #3
0
        public void CustomerAccess_FillGlossary_TestMethod()
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            CustomerAccess.FillDictionary();
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Gender"].Rows.Count > 0);
        }
예제 #4
0
        public void CustomerAccess_GetCustomersByBirthday_TestMethod(int year, int m, int day)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetCustomersByBirthOfDay(new DateTime(year, m, day));
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #5
0
        public void CustomerAccess_GetCustomersByBirthdayBetween_TestMethod()
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetCustomersByBirthdayBetween(new DateTime(1970, 1, 1), new DateTime(2016, 01, 01));
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #6
0
        public void CustomerAccess_GetCustomersByGlossary_TestMethod(string name, string glossary, int Id)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetCustomersByGlossary(name, glossary, Id);
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #7
0
        public void CustomerAccess_GetCustomersByID_TestMethod(int id)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();

            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetCustomersByID(id);
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #8
0
        public void CustomerAccess_GetByAddress_TestMethod(string addr)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();

            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetDataByCriteria("Address", new[] { "Славянск", addr });
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #9
0
        public override object Execute()
        {
            foreach (NewCriteria <int> criteria in _criterias)
            {
                if (criteria != null)
                {
                    CustomerAccess.GetCustomersByGlossary("Customer", criteria.Criteria, criteria.Values[0]);
                }
                break;
            }

            return(CustomerAccess.GetData());
        }
        public void Query_GlossaryQuery_ExecuteMethod_TestMethod(string nameGlossary, int id)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            DataSet           dataSet  = (DataSet)CustomerAccess.GetData();
            NewCriteria <int> criteria = new NewCriteria <int>("=", nameGlossary, id);
            GlossaryQuery     glossary = new GlossaryQuery();

            glossary.Criterias(criteria);
            dataSet = (DataSet)glossary.Execute();
            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
예제 #11
0
        public void CustomerAccess_GetDataByCriteria_TestMethod(string lastname1, string addr1, string lastName2, string addr2)
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();

            CustomerAccess.FillDictionary();
            CustomerAccess.FillCustomerData();
            CustomerAccess.GetDataByCriteria("LastName", new[] { lastname1 }, "=");
            CustomerAccess.GetDataByCriteria("Address", new [] { "Славянск", addr1 }, "=");
            CustomerAccess.GetDataByCriteria("LastName", new[] { lastName2, }, "=");
            CustomerAccess.GetDataByCriteria("Address", new[] { "Славянск", addr2 }, "=");
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0);
        }
        public void Query_CustomerQuery_ExecuteMethod_ParametrWrongId_TestMethod()
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();

            CustomerAccess.FillDictionary();
            DataSet dataSet = (DataSet)CustomerAccess.GetData();

            NewCriteria <int>   criteria      = new NewCriteria <int>("=", "ID", -1);
            CustomerQuery <int> customerQuery = new CustomerQuery <int>();

            customerQuery.Criterias(criteria);
            dataSet = (DataSet)customerQuery.Execute();

            Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count <= 0);
        }
예제 #13
0
 public object FillAll()
 {
     CustomerAccess.FillDictionary();
     CustomerAccess.FillCustomerData();
     return(CustomerAccess.GetData());
 }
예제 #14
0
 public object FindByID(int id)
 {
     CustomerAccess.GetCustomersByID(id);
     return(CustomerAccess.GetData());
 }
예제 #15
0
 public object FindByGlossary(int id, string name)
 {
     CustomerAccess.GetCustomersByGlossary(name, id);
     return(CustomerAccess.GetData());
 }
예제 #16
0
 public object FindBy(string criteria, params object[] values)
 {
     CustomerAccess.GetDataByCriteria(criteria, values);
     return(CustomerAccess.GetData());
 }