Exemplo n.º 1
0
        public void TestRetrieveAll()
        {
            CustomerSQLDB        db        = new CustomerSQLDB(dataSource);
            List <CustomerProps> propsList = (List <CustomerProps>)db.RetrieveAll(db.GetType());

            Assert.AreEqual(696, propsList.Count);
        }
Exemplo n.º 2
0
        public void TestCreate()
        {
            CustomerSQLDB        db       = new CustomerSQLDB(dataSource);
            CustomerProps        p        = new CustomerProps();
            List <CustomerProps> propList = (List <CustomerProps>)db.RetrieveAll(typeof(CustomerProps));

            p.ID            = 800;
            p.name          = "Mary";
            p.city          = "Eugene";
            p.address       = "2249 Hawkins Lane";
            p.state         = "OR";
            p.zipcode       = "97401";
            p.ConcurrencyID = 1;

            Assert.AreEqual(696, propList.Count);

            CustomerProps newProp = (CustomerProps)db.Create(p);

            List <CustomerProps> newList = (List <CustomerProps>)db.RetrieveAll(typeof(CustomerProps));

            Assert.AreEqual(697, newList.Count);
            Assert.AreEqual("Newlin, Sherman", propList[22].name);

            CustomerProps anotherProp = (CustomerProps)db.Create(newProp);
        }
Exemplo n.º 3
0
        public void TestPropAndStringConstructor()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(39);
            Customer      c     = new Customer(props, dataSource);

            Assert.AreEqual("Fernandes, Philip", c.Name);
        }
Exemplo n.º 4
0
        public void TestRetrieve()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(13);

            Assert.AreEqual(13, props.ID);
            Assert.AreEqual("Nichols, Nadine", props.name);
        }
        public void TestRetrieveAll()
        {
            CustomerSQLDB db = new CustomerSQLDB(dataSource);
            // create and fill list of CustomerProps
            List <CustomerProps> cProps = (List <CustomerProps>)db.RetrieveAll(db.GetType());

            // cProps count should be equal to 696 (length of MMABooksUpdated Customers table)
            Assert.AreEqual(696, cProps.Count);
        }
Exemplo n.º 6
0
        public void TestCustomerTextDBRetrieve()
        {
            CustomerSQLDB db    = new CustomerSQLDB(DataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(1);

            Assert.AreEqual(1, props.id);
            Assert.AreEqual("AL", props.state);
            Assert.AreEqual("Birmingham", props.city);
        }
Exemplo n.º 7
0
        public void TestResetDatabase()
        {
            CustomerSQLDB db      = new CustomerSQLDB(dataSource);
            DBCommand     command = new DBCommand();

            command.CommandText = "usp_testingResetData";
            command.CommandType = CommandType.StoredProcedure;
            db.RunNonQueryProcedure(command);
        }
        public void TestRetrieve()
        {
            CustomerSQLDB db = new CustomerSQLDB(dataSource);
            // remember to cast!
            CustomerProps props = (CustomerProps)db.Retrieve(23);

            //23 Newlin, Sherman 2400 Bel Air, Apt. 345 Bronfield CO 80020
            Assert.AreEqual(23, props.ID);
            Assert.AreEqual("Newlin, Sherman", props.name);
        }
Exemplo n.º 9
0
        public void TestDelete()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(8);

            Assert.AreEqual(8, props.ID);
            db.Delete(props);
            var x = Assert.Throws <Exception>(() => db.Retrieve(8));

            Assert.That(x.Message == "Record does not exist in the database.");
        }
Exemplo n.º 10
0
        public void SetUpAllTests()
        {
            db = new CustomerSQLDB(dataSource);
            p  = (CustomerProps)db.Retrieve(1);

            // Resets the database each time.
            DBCommand command = new DBCommand();

            command.CommandText = "usp_testingResetData";
            command.CommandType = CommandType.StoredProcedure;

            db.RunNonQueryProcedure(command);
        }
Exemplo n.º 11
0
        public void TestRetrieve()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(23);

            // 23	Newlin, Sherman	2400 Bel Air, Apt.345	Broomfield	CO	80020           1
            Assert.AreEqual(23, props.ID);
            Assert.AreEqual("Newlin, Sherman", props.name);
            Assert.AreEqual("2400 Bel Air, Apt.345", props.address);
            Assert.AreEqual("Broomfield", props.city);
            Assert.AreEqual("CO", props.state);
            Assert.AreEqual("80020", props.zipcode);
        }
Exemplo n.º 12
0
        public void TestDeleteCustomer()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(7);

            //(7, N'Lutonsky, Christopher', N'293 Old Holcomb Bridge Way', N'Woodland Hills', N'CA', N'91365          ')

            // delete CustomerProps props from the database
            db.Delete(props);

            // attempting to retrieve props from the database should result in exception throw
            Assert.Throws <Exception>(() => db.Retrieve(7));
        }
Exemplo n.º 13
0
        public void TestUpdate()
        {
            CustomerSQLDB db   = new CustomerSQLDB(dataSource);
            Customer      c    = new Customer(39, dataSource);
            string        name = c.Name.ToString();

            c.Name = "Rogers, Trevor";
            c.Save();

            Customer d = new Customer(39, dataSource);

            Assert.AreEqual(d.Name, c.Name);
        }
Exemplo n.º 14
0
        public void TestNewCustomerConstructor3()
        {
            // using CustomerProps and connection string
            CustomerSQLDB db     = new CustomerSQLDB(dataSource);
            CustomerProps cProps = (CustomerProps)db.Retrieve(7);
            // 7  Lutonsky, Christopher  293 Old Holcomb Bridge Way  Woodland Hills CA 91365
            Customer c = new Customer(cProps, dataSource);

            Console.WriteLine(c.ToString());
            Assert.Greater(c.ToString().Length, 1);
            Assert.AreEqual("Woodland Hills", c.City);
            Assert.AreEqual("91365", c.Zipcode);
        }
Exemplo n.º 15
0
        public void TestUpdate()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(13);

            props.state = "NY";
            bool ok = db.Update(props);

            Assert.AreEqual(true, ok);

            CustomerProps propsUpdated = (CustomerProps)db.Retrieve(13);

            Assert.AreEqual("NY", props.state);
        }
Exemplo n.º 16
0
        public void TestUpdate()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(23);

            props.state = "NY";
            bool ok = db.Update(props);

            CustomerProps propsUpdated = (CustomerProps)db.Retrieve(23);

            //23 Newlin, Sherman 2400 Bel Air, Apt. 345 Bronfield CO 80020

            Assert.AreEqual("NY", props.state);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Instantiates mProps and mOldProps as new Props objects.
        /// Instantiates mbdReadable and mdbWriteable as new DB objects.
        /// </summary>
        protected override void SetUp()
        {
            mProps    = new CustomerProps();
            mOldProps = new CustomerProps();

            if (this.mConnectionString == "")
            {
                mdbReadable  = new CustomerSQLDB();
                mdbWriteable = new CustomerSQLDB();
            }

            else
            {
                mdbReadable  = new CustomerSQLDB(this.mConnectionString);
                mdbWriteable = new CustomerSQLDB(this.mConnectionString);
            }
        }
Exemplo n.º 18
0
        public void TestDelete()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = new CustomerProps();

            props.name    = "Trevor";
            props.address = "123 Main St";
            props.city    = "Eugene";
            props.state   = "OR";
            props.zipcode = "97478";

            db.Create(props);

            CustomerProps retCustomer = (CustomerProps)db.Retrieve(props.ID);

            db.Delete(retCustomer);

            Assert.Throws <Exception>(() => db.Retrieve(props.ID));
        }
Exemplo n.º 19
0
        public void Setup()
        {
            db    = new CustomerSQLDB(dataSource);
            props = new CustomerProps();

            DBCommand command = new DBCommand();

            command.CommandText = "usp_testingResetData";
            command.CommandType = CommandType.StoredProcedure;
            db.RunNonQueryProcedure(command);

            testc               = new CustomerProps();
            testc.customerID    = 1;
            testc.name          = "Daisy Duck";
            testc.address       = "12 Banana Dr";
            testc.city          = "Islamorada";
            testc.state         = "FL";
            testc.zipCode       = "85762";
            testc.concurrencyID = 1;
        }
Exemplo n.º 20
0
        public void TestCreate()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = new CustomerProps();

            props.name    = "Trevor";
            props.address = "123 Main St";
            props.city    = "Eugene";
            props.state   = "OR";
            props.zipcode = "97478";

            db.Create(props);

            CustomerProps retCustomer = (CustomerProps)db.Retrieve(props.ID);

            Assert.AreEqual("Trevor", retCustomer.name);
            Assert.AreEqual("123 Main St", retCustomer.address);
            Assert.AreEqual("Eugene", retCustomer.city);
            Assert.AreEqual("OR", retCustomer.state);
            Assert.AreEqual("97478", retCustomer.zipcode);
        }
Exemplo n.º 21
0
        public void TestUpdate()
        {
            CustomerSQLDB db    = new CustomerSQLDB(dataSource);
            CustomerProps props = (CustomerProps)db.Retrieve(23);

            props.name    = "zzz";
            props.address = "zzz";
            props.city    = "zzz";
            props.state   = "OR";
            props.zipcode = "97478";

            db.Update(props);

            CustomerProps propsUpdated = (CustomerProps)db.Retrieve(23);

            Assert.AreEqual("zzz", propsUpdated.name);
            Assert.AreEqual("zzz", propsUpdated.address);
            Assert.AreEqual("zzz", propsUpdated.city);
            Assert.AreEqual("OR", propsUpdated.state);
            Assert.AreEqual("97478", propsUpdated.zipcode);
        }
Exemplo n.º 22
0
        public void TestCreateCustomer()
        {
            CustomerSQLDB db = new CustomerSQLDB(dataSource);
            // declare and instantiate new CustomerProps c
            CustomerProps c = new CustomerProps();

            c.name    = "John Rolfe";
            c.address = "1 Branch Hut";
            c.city    = "Jamestown";
            c.state   = "VA";
            c.zipcode = "23233";

            // Create record for c in the database
            db.Create(c);

            // Retrieve Customer c from the database and store in variable cCreated
            CustomerProps cCreated = (CustomerProps)db.Retrieve(c.ID);

            Assert.AreEqual("John Rolfe", cCreated.name);
            Assert.AreEqual("23233", cCreated.zipcode);
        }