public void FriendUsersTest() { for (int i = 0; i < 2; i++) { DBConnectionHelper.ExecuteNonQuery(DBConnectionHelper.MakeSQLInsertQuery(DBConnectionHelper._tableUser, new String[] { DBConnectionHelper._columnName, DBConnectionHelper._columPasword, DBConnectionHelper._columnEmail, DBConnectionHelper._columnGuid }, new String[] { "Username" + i.ToString("00"), "Password" + i.ToString("00"), "email" + i.ToString("00") + "@mail.de", Guid.NewGuid().ToString() })); } Thread.Sleep(1000); List <Record> list = DBConnectionHelper.ReadUserRecords(); int userID1 = Convert.ToInt32(list[0].Entries["ID"]); int userID2 = Convert.ToInt32(list[1].Entries["ID"]); bool re = DBConnectionHelper.FriendUsers(userID1, userID2); Assert.AreEqual(true, re); List <int> actual = DBConnectionHelper.ReadBuddiesFromUser(userID1); Assert.AreEqual(1, actual.Count); Assert.AreEqual(userID2, actual[0]); actual = DBConnectionHelper.ReadBuddiesFromUser(userID2); Assert.AreEqual(1, actual.Count); Assert.AreEqual(userID1, actual[0]); }
public void DeleteUserTest() { FriendUsersTest(); List <Record> list = DBConnectionHelper.ReadUserRecords(); Assert.AreEqual(2, list.Count); int id = Convert.ToInt32(list[0].Entries["ID"]); bool actual = DBConnectionHelper.DeleteUser(id); Assert.AreEqual(true, actual); list = DBConnectionHelper.ReadUserRecords(); Assert.AreEqual(1, list.Count); List <int> buddies = DBConnectionHelper.ReadBuddiesFromUser(id); Assert.AreEqual(0, buddies.Count); }
public void ReadBuddiesFromUserTest() { int id = 1; int expected = 0; List <int> actual; actual = DBConnectionHelper.ReadBuddiesFromUser(id); Assert.IsNotNull(actual); Assert.AreEqual(expected, actual.Count); int count = 3; for (int i = 0; i < count; i++) { DBConnectionHelper.ExecuteNonQuery(DBConnectionHelper.MakeSQLInsertQuery(DBConnectionHelper._tableUser, new String[] { DBConnectionHelper._columnName, DBConnectionHelper._columPasword, DBConnectionHelper._columnEmail, DBConnectionHelper._columnGuid }, new String[] { "Username" + i.ToString("00"), "Password" + i.ToString("00"), "email" + i.ToString("00") + "@mail.de", Guid.NewGuid().ToString() })); } Thread.Sleep(1000); List <Record> list = DBConnectionHelper.ReadUserRecords(); for (int i = 0; i < count - 1; i++) { DBConnectionHelper.FriendUsers(Convert.ToInt32(list[0].Entries["ID"]), Convert.ToInt32(list[i + 1].Entries["ID"])); } actual = DBConnectionHelper.ReadBuddiesFromUser(Convert.ToInt32(list[0].Entries["ID"])); for (int i = 0; i < count - 1; i++) { Assert.IsTrue(actual.Contains(Convert.ToInt32(list[i + 1].Entries["ID"])), "Expected ID " + list[i + 1].Entries["ID"] + " not found"); } Assert.AreEqual(count - 1, actual.Count); }
public void UnfriendUsersTest() { FriendUsersTest(); List <Record> list = DBConnectionHelper.ReadUserRecords(); Assert.AreEqual(2, list.Count); int userID1 = Convert.ToInt32(list[0].Entries["ID"]); int userID2 = Convert.ToInt32(list[1].Entries["ID"]); bool actual = DBConnectionHelper.UnfriendUsers(userID1, userID2); Assert.AreEqual(true, actual); list = DBConnectionHelper.ReadUserRecords(); Assert.AreEqual(2, list.Count); List <int> buddies = DBConnectionHelper.ReadBuddiesFromUser(userID1); Assert.AreEqual(0, buddies.Count); buddies = DBConnectionHelper.ReadBuddiesFromUser(userID2); Assert.AreEqual(0, buddies.Count); }