示例#1
0
        public void DBSalespersonTest_Get_invalidID()
        {
            DBSalesperson dBSalesperson = new DBSalesperson();
            const int     id            = -1;

            var result = dBSalesperson.Get(id);
        }
        public District DeleteSecondaryFromDistrict(int districtId, int personId)
        {
            var faulted = new District();

            try
            {
                DBSalesperson personDb = new DBSalesperson();
                var           person   = personDb.Get(personId);
                var           district = db.Get(districtId);
                db.DeleteSecondary(person, district);
                return(new District()
                {
                    IsFaulted = false
                });
            }
            catch (DataLayerArgumentException e)
            {
                faulted.IsFaulted = true;
                faulted.DataLayerArgumentException = e.Message;
            }
            catch (DataLayerException e)
            {
                faulted.IsFaulted          = true;
                faulted.DataLayerException = e.Message;
            }
            return(faulted);
        }
示例#3
0
        public void DBSalespersonTest_Update_Fail_Name()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(4);

            person.Name = String.Empty;

            db.Update(person);
        }
示例#4
0
        public void DBSalespersonTest_Update_Fail_ID()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.Id = -2;

            db.Update(person);
        }
示例#5
0
        public void DBSalespersonTest_Update_Fail_LastName()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.LastName = null;

            db.Update(person);
        }
示例#6
0
        public void DBSalespersonTest_Get_valid()
        {
            DBSalesperson dBSalesperson = new DBSalesperson();
            const int     id            = 1;
            const string  EXPECTED      = "Mike";

            var result = dBSalesperson.Get(id);

            Assert.AreEqual(EXPECTED, result.Name);
        }
示例#7
0
        public void DBSalespersonTest_Update()
        {
            DBSalesperson db      = new DBSalesperson();
            var           person  = db.Get(3);
            string        nameOld = person.Name;
            string        nameNew = "Jason";

            person.Name = nameNew;

            db.Update(person);
            person = null;

            person = db.Get(3);

            Assert.AreEqual(nameNew, person.Name);

            //cleanup
            person.Name = nameOld;
            db.Update(person);
        }
        // GET: api/Salesperson/5
        public Salesperson Get(int id)
        {
            var faulted = new Salesperson();

            try
            {
                return(db.Get(id));
            }
            catch (DatabaseLink.DataLayerArgumentException e)
            {
                faulted.IsFaulted = true;
                faulted.DataLayerArgumentException = e.Message;
            }
            catch (DatabaseLink.DataLayerException e)
            {
                faulted.IsFaulted          = true;
                faulted.DataLayerException = e.Message;
            }
            return(faulted);
        }