public static void TestGetUser() { User demoUser = new User(); UserController userCtr = new UserController(); string username = "******"; string password = "******"; demoUser = userCtr.GetUser(username, password); if (demoUser != null) { Console.WriteLine("succes \n"); //if (user.Username == username && user.Password == password) //{ // Console.WriteLine("more succes"); //} //else //{ // Console.WriteLine("incorrect username found"); //} Console.WriteLine("UserID: " + demoUser.UserId.ToString() + "\n"); Console.WriteLine("Username: "******"\n"); Console.WriteLine("Password: "******"\n"); Console.WriteLine("Age: " + demoUser.Age.ToString() + "\n"); Console.WriteLine("Weight: " + demoUser.Weight.ToString() + "\n"); //List<Achievement> list = userCtr.GetUsersAchievements(6); //Console.WriteLine("ach test: " + list[0].Name.ToString()); Console.WriteLine("Achievement: " + demoUser.Achievements[0].Name.ToString()); Console.WriteLine("Title: " + demoUser.Titles[0].Name.ToString()); Console.ReadLine(); //Console.WriteLine("Achievements: " + "\n"); //foreach (Achievement a in demoUser.Achievements) //{ // Console.WriteLine("Achievement: " + a.Name + "\n"); //} //Console.WriteLine("user has no achievements"); //Console.WriteLine("Titles: " + "\n"); //foreach (Title t in demoUser.Titles) //{ // Console.WriteLine("Title: " + t.Name + "\n"); //} //Console.WriteLine("user has no titles"); //Console.WriteLine("user is null"); } }
public void TestCreateUser() { /* create a user | check that he can be found in db | compare */ string UserNameExpected = "MrArnold"; string PassWordExpected = "Wuaa"; string NameExpected = "Schwarz"; int AgeExpected = 22; double WeightExpected = 92; double HeightExpected = 185; long XpExpected = 1292; int LevelExpected = 2; string privacyName = "none"; string privacyAge = "none"; string privacyHeight = "none"; string privacyWeight = "none"; // Add the expected user to DB UserController userCtr = new UserController(); userCtr.AddUserToDb(UserNameExpected,PassWordExpected,NameExpected,AgeExpected,WeightExpected,HeightExpected,XpExpected,LevelExpected,privacyName, privacyAge, privacyHeight, privacyWeight); /* GET THE ACTUAL USER FROM USERNAME AND PASSWORD */ User actualUser = new User(); actualUser = userCtr.GetUser(UserNameExpected,PassWordExpected); // Properties of the Actual user - retrieved from DB string userNameActual = actualUser.UserName; string passWordActual = actualUser.Password; string nameActual = actualUser.Name; int ageActual = actualUser.Age; double weightActual = actualUser.Weight; double heightActual = actualUser.Height; long xpActual = actualUser.Xp; int levelActual = actualUser.Level; /* COMPARE */ Assert.AreEqual(UserNameExpected,userNameActual); Assert.AreEqual(PassWordExpected,passWordActual); Assert.AreEqual(NameExpected,nameActual); Assert.AreEqual(AgeExpected,ageActual); Assert.AreEqual(WeightExpected,weightActual); Assert.AreEqual(HeightExpected,heightActual); Assert.AreEqual(XpExpected,xpActual); Assert.AreEqual(LevelExpected,levelActual); // DONE }
public void TestGetUser() { /* define user stats | find user on those stats | see if test can get the equivalent data in db */ /* EXPECTED */ int UserIdExpected = 1; string UserNameExpected = "derp"; string PassWordExpected = "1234"; string NameExpected = "niels"; int AgeExpected = 17; int WeightExpected = 80; int HeightExpected = 175; long LevelExpected = 2; int XpExpected = 4178; /* GET THE USER */ UserController userctr = new UserController(); User expectedUser = new User(); expectedUser = userctr.GetUser(UserNameExpected, PassWordExpected); /* COMPARE */ int useridActual = expectedUser.UserId; string usernameActual = expectedUser.UserName; string passwordActual = expectedUser.Password; string nameActual = expectedUser.Name; int ageActual = expectedUser.Age; double weightActual = expectedUser.Weight; double heightActual = expectedUser.Height; long xpActual = expectedUser.Xp; int levelActual = expectedUser.Level; Assert.AreEqual(UserIdExpected,useridActual); Assert.AreEqual(UserNameExpected, usernameActual); Assert.AreEqual(PassWordExpected, passwordActual); Assert.AreEqual(NameExpected,nameActual); Assert.AreEqual(AgeExpected,ageActual); Assert.AreEqual(WeightExpected,weightActual); Assert.AreEqual(HeightExpected,heightActual); Assert.AreEqual(XpExpected,xpActual); Assert.AreEqual(LevelExpected, levelActual); // DONE // }
public void TestUpdateUser() { UserController userCtr = new UserController(); string userName = "******"; string passWord = "******"; long xp = 1; User userToUpdate = new User(); User userafterupdate = new User(); /* EXPECTED */ // The user to update userToUpdate = userCtr.GetUser(userName, passWord); // Expected xp long xpbeforeupdate = userToUpdate.Xp; /* THE UPDATE */ // Update the user with username with amount of xp userCtr.UpdateUserXP(userName, xp); /* ACTUAL */ // Get the user after the update - Retrieved from DB userafterupdate = userCtr.GetUser(userName, passWord); // Actual xp long xpafterupdate = (userafterupdate.Xp)-1; // remember to increment manually before running test /* COMPARE */ Assert.AreEqual(xpbeforeupdate, xpafterupdate); // we always test for an increment of one only }