Exemple #1
0
        public void TestRetrieveAll()
        {
            ProductSQLDB        db        = new ProductSQLDB(dataSource);
            List <ProductProps> propsList = (List <ProductProps>)db.RetrieveAll(db.GetType());

            Assert.AreEqual(16, propsList.Count);
        }
        public void TestRetrieve()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(2);

            Assert.AreEqual(2, props.ID);
        }
Exemple #3
0
        public void TestPropAndStringConstructor()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(1);
            Product      c     = new Product(props, dataSource);

            Assert.AreEqual("A4CS      ", c.ProductCode);
        }
        public void TestResetDatabase()
        {
            ProductSQLDB db      = new ProductSQLDB(dataSource);
            DBCommand    command = new DBCommand();

            command.CommandText = "usp_testingResetData";
            command.CommandType = CommandType.StoredProcedure;
            db.RunNonQueryProcedure(command);
        }
        public void TestRetrieveAll()
        {
            ProductSQLDB db = new ProductSQLDB(dataSource);
            // create and fill list of ProductProps
            List <ProductProps> cProps = (List <ProductProps>)db.RetrieveAll(db.GetType());

            // cProps count should be equal to 16 (length of MMABooksUpdated Products table)
            Assert.AreEqual(16, cProps.Count);
        }
Exemple #6
0
        public void TestProductTextDBRetrieve()
        {
            ProductSQLDB db    = new ProductSQLDB(DataSource);
            ProductProps props = (ProductProps)db.Retrieve(1);

            Assert.AreEqual(1, props.id);
            Assert.AreEqual("A4CS", props.code);
            Assert.AreEqual(4637, props.onHandQty);
        }
        public void TestDelete()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)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.");
        }
        public void TestRetrieve()
        {
            ProductSQLDB db = new ProductSQLDB(dataSource);
            // remember to cast!
            ProductProps props = (ProductProps)db.Retrieve(6);

            // 6    CS10    Murach's C# 2010   56.50   80020  5136
            Assert.AreEqual(6, props.ID);
            Assert.AreEqual("Murach's C# 2010", props.description);
            Assert.AreEqual(56.50, props.unitPrice);
        }
Exemple #9
0
        public void TestRetrieve()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(1);

            //1   A4CS Murach's ASP.NET 4 Web Programming with C# 2010	56.5000	4637	1
            Assert.AreEqual(1, props.ID);
            Assert.AreEqual("A4CS", props.ProductCode.Trim());
            Assert.AreEqual("Murach's ASP.NET 4 Web Programming with C# 2010", props.Description);
            Assert.AreEqual(56.5000, props.UnitPrice);
            Assert.AreEqual(4637, props.OnHandQuantity);
        }
        public void TestNewProductConstructor3()
        {
            // using ProductProps and connection string
            ProductSQLDB db     = new ProductSQLDB(dataSource);
            ProductProps pProps = (ProductProps)db.Retrieve(14);
            // 14    SQ12    Murach's SQL Server 2012     57.50   2465
            Product p = new Product(pProps, dataSource);

            Console.WriteLine(p.ToString());
            Assert.Greater(p.ToString().Length, 1);
            Assert.AreEqual("Murach's SQL Server 2012", p.Description);
            Assert.AreEqual(57.50M, p.UnitPrice);
        }
Exemple #11
0
        public void TestUpdate()
        {
            ProductSQLDB db       = new ProductSQLDB(dataSource);
            Product      c        = new Product(1, dataSource);
            string       prodCode = c.ProductCode.ToString();

            c.ProductCode = "zzzz      ";
            c.Save();

            Product d = new Product(1, dataSource);

            Assert.AreEqual(d.ProductCode, c.ProductCode);
        }
        public void TestDeleteProduct()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(14);

            //14    SQ12    Murach's SQL Server 2012     57.50   2465

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

            // attempting to retrieve props from the database should result in exception throw
            Assert.Throws <Exception>(() => db.Retrieve(14));
        }
        public void TestUpdate()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(13);

            props.description = "Description";
            bool ok = db.Update(props);

            Assert.AreEqual(true, ok);

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

            Assert.AreEqual("Description", props.description);
        }
        public void TestSaveToDataStore()
        {
            ProductSQLDB db = new ProductSQLDB(dataSource);
            Product      p  = new Product(dataSource);

            p.ProductCode    = "FS10";
            p.Description    = "Murach's F# 2010";
            p.UnitPrice      = 45.00M;
            p.OnHandQuantity = 99;
            p.Save();

            Assert.AreEqual("Murach's F# 2010", p.Description);
            Assert.AreEqual(99, p.OnHandQuantity);
        }
        public void TestUpdate()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(14);

            props.unitPrice = 55.50M;
            bool ok = db.Update(props);

            ProductProps propsUpdated = (ProductProps)db.Retrieve(14);

            //14    SQ12    Murach's SQL Server 2012     57.50   2465

            Assert.AreEqual("SQ12", props.prodCode);
            Assert.AreEqual(55.50M, props.unitPrice);
        }
Exemple #16
0
        public void TestDelete()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = new ProductProps();

            props.ProductCode    = "zzz       ";
            props.Description    = "zzz";
            props.UnitPrice      = 120.00m;
            props.OnHandQuantity = 1234;

            db.Create(props);

            ProductProps createdProduct = (ProductProps)db.Retrieve(props.ID);

            db.Delete(createdProduct);

            Assert.Throws <Exception>(() => db.Retrieve(props.ID));
        }
Exemple #17
0
        public void Setup()
        {
            db    = new ProductSQLDB(dataSource);
            props = new ProductProps();

            DBCommand command = new DBCommand();

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

            testp               = new ProductProps();
            testp.ID            = 1;
            testp.quantity      = 10;
            testp.code          = "XXXX";
            testp.price         = 99.99m;
            testp.description   = "This is a test product";
            testp.ConcurrencyID = 1;
        }
Exemple #18
0
        public void TestUpdate()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = (ProductProps)db.Retrieve(1);

            props.ProductCode    = "zzz       ";
            props.Description    = "zzz";
            props.UnitPrice      = 120.00m;
            props.OnHandQuantity = 1234;

            db.Update(props);

            ProductProps propsUpdated = (ProductProps)db.Retrieve(1);

            Assert.AreEqual("zzz       ", propsUpdated.ProductCode);
            Assert.AreEqual("zzz", propsUpdated.Description);
            Assert.AreEqual(120.00m, propsUpdated.UnitPrice);
            Assert.AreEqual(1234, propsUpdated.OnHandQuantity);
        }
Exemple #19
0
        public void TestCreate()
        {
            ProductSQLDB db    = new ProductSQLDB(dataSource);
            ProductProps props = new ProductProps();

            props.ProductCode    = "zzz       ";
            props.Description    = "zzz";
            props.UnitPrice      = 120.00m;
            props.OnHandQuantity = 1234;

            db.Create(props);

            ProductProps createdProduct = (ProductProps)db.Retrieve(props.ID);

            Assert.AreEqual("zzz       ", createdProduct.ProductCode);
            Assert.AreEqual("zzz", createdProduct.Description);
            Assert.AreEqual(120.00m, createdProduct.UnitPrice);
            Assert.AreEqual(1234, createdProduct.OnHandQuantity);
        }
        public void TestCreateProduct()
        {
            ProductSQLDB db = new ProductSQLDB(dataSource);
            // declare and instantiate new ProductProps p
            ProductProps p = new ProductProps();

            p.prodCode       = "FS30";
            p.description    = "Murach's F# 2015";
            p.unitPrice      = 50.00M;
            p.onHandQuantity = 100;

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

            // Retrieve Product p from the database and store in variable pCreated
            ProductProps pCreated = (ProductProps)db.Retrieve(p.ID);

            Assert.AreEqual("FS30", pCreated.prodCode);
            Assert.AreEqual(100, pCreated.onHandQuantity);
        }
        public void TestCreate()
        {
            ProductSQLDB        db       = new ProductSQLDB(dataSource);
            ProductProps        p        = new ProductProps();
            List <ProductProps> propList = (List <ProductProps>)db.RetrieveAll(typeof(ProductProps));

            p.ID             = 800;
            p.description    = "Description";
            p.onhandquantity = 400;
            p.unitprice      = 515.25m;
            p.ConcurrencyID  = 1;

            Assert.AreEqual(16, propList.Count);

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

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

            Assert.AreEqual(17, newList.Count);
            Assert.AreEqual(52.50m, propList[9].unitprice);

            ProductProps anotherProp = (ProductProps)db.Create(newProp);
        }