public void CreateHostTest()
        {
            DataLayerBase target   = DataLayerFactory.Instance.GetDataLayer(DataLayerType.SqlServer);
            string        hostName = "LG";

            target.CreateHost(hostName);

            string filePath = @"c:\LG\chamame.mp3";
            string album    = "Chamame";
            string artist   = "Tarrago Ross";
            string title    = "Curuzu Cuatia";
            int    year     = 1966;
            string genre    = "Folklore";

            target.CreateOrUpdateMusicTrack(hostName, filePath, album, artist, title, year, genre);

            int totalHostCount = 0;

            if (target.GetAllHosts() != null)
            {
                totalHostCount = target.GetAllHosts().Rows.Count;
            }

            Assert.AreEqual(2, totalHostCount, "It should be 2 Host on the database.");
        }
        public void TestConnectionTest()
        {
            DataLayerBase target   = DataLayerFactory.Instance.GetDataLayer(DataLayerType.SqlServer);
            bool          expected = true;
            bool          actual;

            actual = target.TestConnection();
            Assert.AreEqual(expected, actual, "Test connection fail.");
        }
        public void HostExistsTest()
        {
            DataLayerBase target   = DataLayerFactory.Instance.GetDataLayer(DataLayerType.SqlServer);
            string        hostName = "Frostmourne";
            bool          actual;

            actual = target.HostExists(hostName);
            Assert.AreEqual(true, actual, "Host Frostmourne should exists.");
        }
Beispiel #4
0
      public static DataTable GettblExpenses(DbTransaction tran, object expenseId)
      {
          DataTable retVal = new DataTable();

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_GettblExpenses");

          db.AddInParameter(cmd, "@expenseId", DbType.Double, expenseId);

          retVal = DataLayerBase.ExecuteDataSet(db, tran, cmd).Tables[0];

          return(retVal);
      }
Beispiel #5
0
      public static int DeletetblExpenses(DbTransaction tran, object expenseId)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_DeletetblExpenses");

          db.AddInParameter(cmd, "@expenseId", DbType.Double, expenseId);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }
        public void CreateOrUpdateMusicTrackTest()
        {
            DataLayerBase target = DataLayerFactory.Instance.GetDataLayer(DataLayerType.SqlServer);

            string hostName = "Frostmourne";

            target.CreateHost(hostName);

            string filePath = @"c:\Music\chamame.mp3";
            string album    = "Chamame";
            string artist   = "Tarrago Ross";
            string title    = "Curuzu Cuatia";
            int    year     = 1966;
            string genre    = "Folklore";

            target.CreateOrUpdateMusicTrack(hostName, filePath, album, artist, title, year, genre);

            filePath = @"c:\Music\coco.mp3";
            album    = "Greatest Hits";
            artist   = "Roxette";
            title    = "Dangerous";
            year     = 2004;
            genre    = "Rock";
            target.CreateOrUpdateMusicTrack(hostName, filePath, album, artist, title, year, genre);

            filePath = @"c:\Music\Arjona\pinguinos en la cama.mp3";
            album    = "Arjona";
            artist   = "Ricardo Arjona";
            title    = "Pinguinos en la cama";
            year     = 2005;
            genre    = "Melódico";
            target.CreateOrUpdateMusicTrack(hostName, filePath, album, artist, title, year, genre);

            DataTable dt = target.Search(album, artist, title, year, genre);

            Assert.AreEqual(1, dt.Rows.Count, "Music Track creation fail.");
            if (dt.Rows.Count > 0)
            {
                Guid    musicTrackId = new Guid(dt.Rows[0][DBConstants.MusicTrackId].ToString());
                DataRow dr           = target.GetMusicTrack(musicTrackId);
                if (dr != null)
                {
                    Assert.AreEqual(artist, dr[DBConstants.Artist].ToString(), "GetMusicTrack fail.");
                }
            }
        }
Beispiel #7
0
      public static int UpdatetblSupply(DbTransaction tran, DateTime createdDate, DateTime modifiedDate, string supplyDescription, double supplyId, string supplyName)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_UpdatetblSupply");

          db.AddInParameter(cmd, "@createdDate", DbType.DateTime, createdDate);
          db.AddInParameter(cmd, "@modifiedDate", DbType.DateTime, modifiedDate);
          db.AddInParameter(cmd, "@supplyDescription", DbType.String, supplyDescription);
          db.AddInParameter(cmd, "@supplyId", DbType.Double, supplyId);
          db.AddInParameter(cmd, "@supplyName", DbType.String, supplyName);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }
Beispiel #8
0
      public static int InserttblExpenses(DbTransaction tran, DateTime createdDate, string expenseAmount, string expenseDescription, double expenseId, string expenseName, DateTime modifiedDate)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_InserttblExpenses");

          db.AddInParameter(cmd, "@createdDate", DbType.DateTime, createdDate);
          db.AddInParameter(cmd, "@expenseAmount", DbType.String, expenseAmount);
          db.AddInParameter(cmd, "@expenseDescription", DbType.String, expenseDescription);
          db.AddInParameter(cmd, "@expenseId", DbType.Double, expenseId);
          db.AddInParameter(cmd, "@expenseName", DbType.String, expenseName);
          db.AddInParameter(cmd, "@modifiedDate", DbType.DateTime, modifiedDate);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }
Beispiel #9
0
      public static int InserttblProducts(DbTransaction tran, DateTime createdDate, DateTime modifiedDate, string productCode, string productDescription, double productId, string productName)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_InserttblProducts");

          db.AddInParameter(cmd, "@createdDate", DbType.DateTime, createdDate);
          db.AddInParameter(cmd, "@modifiedDate", DbType.DateTime, modifiedDate);
          db.AddInParameter(cmd, "@productCode", DbType.String, productCode);
          db.AddInParameter(cmd, "@productDescription", DbType.String, productDescription);
          db.AddInParameter(cmd, "@productId", DbType.Double, productId);
          db.AddInParameter(cmd, "@productName", DbType.String, productName);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }
Beispiel #10
0
      public static int UpdatetblProductSupply(DbTransaction tran, string costPrice, DateTime createdDate, string maxSellingPrice, string minSellingPrice, DateTime modifiedDate, double productId, double productSupplyId, string quantityAtHand, string suppliedQuantity, double supplyId)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_UpdatetblProductSupply");

          db.AddInParameter(cmd, "@costPrice", DbType.String, costPrice);
          db.AddInParameter(cmd, "@createdDate", DbType.DateTime, createdDate);
          db.AddInParameter(cmd, "@maxSellingPrice", DbType.String, maxSellingPrice);
          db.AddInParameter(cmd, "@minSellingPrice", DbType.String, minSellingPrice);
          db.AddInParameter(cmd, "@modifiedDate", DbType.DateTime, modifiedDate);
          db.AddInParameter(cmd, "@productId", DbType.Double, productId);
          db.AddInParameter(cmd, "@productSupplyId", DbType.Double, productSupplyId);
          db.AddInParameter(cmd, "@quantityAtHand", DbType.String, quantityAtHand);
          db.AddInParameter(cmd, "@suppliedQuantity", DbType.String, suppliedQuantity);
          db.AddInParameter(cmd, "@supplyId", DbType.Double, supplyId);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }
        public void SearchTest()
        {
            DataLayerBase target = DataLayerFactory.Instance.GetDataLayer(DataLayerType.SqlServer);
            DataTable     actual;

            //all fields
            string album  = "Greatest Hits";
            string artist = "Roxette";
            string title  = "Dangerous";
            int    year   = 2004;
            string genre  = "Rock";

            actual = target.Search(album, artist, title, year, genre);
            if (actual != null)
            {
                Assert.AreEqual(1, actual.Rows.Count, "Search all field failed.");
                Assert.AreEqual(@"c:\Music\coco.mp3", actual.Rows[0][DBConstants.Path].ToString(), "Search result path mismatch.");
            }
            else
            {
                Assert.IsTrue(true, "DataTable from search is null.");
            }
        }
Beispiel #12
0
      public static int UpdatetblSales(DbTransaction tran, string actualSellingPrice, string costPrice, DateTime createdDate, DateTime modifiedDate, string packType, double productId, string profit, string quantity, double saleId, double supplyId)
      {
          int retVal = -1;

          Database db = DatabaseFactory.CreateDatabase();

          DbCommand cmd = db.GetStoredProcCommand("proc_UpdatetblSales");

          db.AddInParameter(cmd, "@actualSellingPrice", DbType.String, actualSellingPrice);
          db.AddInParameter(cmd, "@costPrice", DbType.String, costPrice);
          db.AddInParameter(cmd, "@createdDate", DbType.DateTime, createdDate);
          db.AddInParameter(cmd, "@modifiedDate", DbType.DateTime, modifiedDate);
          db.AddInParameter(cmd, "@packType", DbType.String, packType);
          db.AddInParameter(cmd, "@productId", DbType.Double, productId);
          db.AddInParameter(cmd, "@profit", DbType.String, profit);
          db.AddInParameter(cmd, "@quantity", DbType.String, quantity);
          db.AddInParameter(cmd, "@saleId", DbType.Double, saleId);
          db.AddInParameter(cmd, "@supplyId", DbType.Double, supplyId);

          retVal = DataLayerBase.ExecuteNonQuery(db, tran, cmd);

          return(retVal);
      }