public int ChangeConsignmentID(ChangeConsignmentID cci) { SqlConnection connection = new SqlConnection(Connection.connectionString()); SqlCommand command = new SqlCommand("usp_changeConsignmentID"); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@ItemID", cci.ItemID)); command.Parameters.Add(new SqlParameter("@NewConsignmentID", cci.NewConsignmentID)); command.Connection = connection; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); connection.Close(); if (table.Rows.Count > 0 && table.Rows[0][0].ToString() == cci.NewConsignmentID.ToString()) { return(1); } else { return(0); } }
public void ChangeConsignmentIDTest() { ChangeConsignmentID cci = new ChangeConsignmentID(); cci.ItemID = GetItemID(); cci.NewConsignmentID = GetConsignmentID(); int result = controller.ChangeConsignmentID(cci); Assert.AreEqual(result, 1); }