public void SportType_FindParent() { //Create a SportType object to be the parent string sportTypeNameUsed = "Deporte Padre"; Int64 parentSportTypeIDUsed = 0; string memoUsed = "Deporte padre"; Int64 userIDUsed = 85; SportTypes aSportTypeParent = new SportTypes(); aSportTypeParent.LoadData(-1, sportTypeNameUsed, parentSportTypeIDUsed, memoUsed, userIDUsed,1); //Save into BD obtaining the sportTypeID aSportTypeParent = aSportTypeParent.SaveData(connString); Assert.AreNotEqual(0, aSportTypeParent.SportTypeID); //saving correct data //Create a SportType object to be the child sportTypeNameUsed = "Deporte Hijo"; parentSportTypeIDUsed = aSportTypeParent.SportTypeID; memoUsed = "Deporte Hijo"; userIDUsed = 85; SportTypes aSportTypeChild = new SportTypes(); aSportTypeChild.LoadData(-1, sportTypeNameUsed, parentSportTypeIDUsed, memoUsed, userIDUsed,1); //Save into BD obtaining the sportTypeID aSportTypeChild = aSportTypeChild.SaveData(connString); Assert.AreNotEqual(0, aSportTypeChild.SportTypeID); //saving correct data //Try to find the parent sport type. SportTypes parentSportTypeToFind = new SportTypes(); parentSportTypeToFind = aSportTypeChild.FindParentSportType(connString); Assert.AreNotEqual(-1, parentSportTypeToFind.SportTypeID); //Found it!! Assert.AreEqual(aSportTypeParent.SportTypeID, parentSportTypeToFind.SportTypeID); Assert.AreEqual(aSportTypeParent.SportTypeName, parentSportTypeToFind.SportTypeName); Assert.AreEqual(aSportTypeParent.ParentSportTypeID, parentSportTypeToFind.ParentSportTypeID,1); Assert.AreEqual(aSportTypeParent.Memo, parentSportTypeToFind.Memo); //Deleting object previously saved int res = aSportTypeParent.Delete(connString); Assert.AreEqual(1, res); //Deleting object previously saved res = aSportTypeChild.Delete(connString); Assert.AreEqual(1, res); }
public void SportType_Update() { //Create a SportType object string sportTypeNameUsed = "Bicicleta"; Int64 parentSportTypeIDUsed = 0; string memoUsed = "Deportes de bicicleta"; Int64 userIDUsed = 85; SportTypes aSportType = new SportTypes(); aSportType.LoadData(-1, sportTypeNameUsed, parentSportTypeIDUsed, memoUsed, userIDUsed,1); //Save into BD obtaining the sportTypeID aSportType = aSportType.SaveData(connString); Assert.AreNotEqual(0, aSportType.SportTypeID); Assert.AreNotEqual(0, aSportType.SportTypeID); //saving correct data Int64 sportTypeIDUsed = aSportType.SportTypeID; //Try to find and check values aSportType = aSportType.FindSportTypeByName(connString); Assert.AreNotEqual(-1, aSportType.SportTypeID); Assert.AreEqual(sportTypeNameUsed, aSportType.SportTypeName); Assert.AreEqual(parentSportTypeIDUsed, aSportType.ParentSportTypeID); Assert.AreEqual(memoUsed, aSportType.Memo); Assert.AreEqual(userIDUsed, aSportType.UserID); //Update values sportTypeNameUsed = "Bike Updated"; parentSportTypeIDUsed = 0; memoUsed = "Deportes de bicicleta updated"; userIDUsed = 85; aSportType.LoadData(sportTypeIDUsed, sportTypeNameUsed, parentSportTypeIDUsed, memoUsed, userIDUsed,1); aSportType.UpdateData(connString); //Try to find and check values aSportType = aSportType.FindSportTypeByName(connString); Assert.AreNotEqual(-1, aSportType.SportTypeID); Assert.AreEqual(sportTypeNameUsed, aSportType.SportTypeName); Assert.AreEqual(parentSportTypeIDUsed, aSportType.ParentSportTypeID); Assert.AreEqual(memoUsed, aSportType.Memo); Assert.AreEqual(userIDUsed, aSportType.UserID); //Deleting object previously saved int res = aSportType.Delete(connString); Assert.AreEqual(1, res); //Try to find again after deleting aSportType = aSportType.FindSportTypeByID(connString); Assert.AreEqual(-1, aSportType.SportTypeID); }