public void Check_AddUser() { // ARRANGE using IPizzaboxRepository pizzaboxRepository = DbOptions.CreatePizzaboxRepository(); User U1 = new User { Username = "******", Pass = "******", FullName = "Yah Who", SessionLive = 0 }; User Expected = U1; // ACT pizzaboxRepository.AddUser(U1); User Actual = pizzaboxRepository.GetUserById("whaa"); // ASSERT Assert.Equal(Expected, Actual); }
internal static User Signup() { using IPizzaboxRepository pizzaboxRepository = DbOptions.CreatePizzaboxRepository(); User newUser = new User { Username = "", Pass = "", FullName = "", SessionLive = 0 }; #region Header Console.WriteLine("SIGN UP"); Console.WriteLine("You're one step away from being a Pizza Box member!"); Console.WriteLine("___________________________________________________"); #endregion #region Choose Account Type trials = 3; string answer; do { Console.Write("Account Type (customer or employee): "); answer = Console.ReadLine(); if (answer.ToLower() == "employee") { if (pizzaboxRepository.GetUserById("admin") != null) { Utilities.Error("exists"); } /* * if (DB.User.Any(u => u.Username == "admin")) * Error("exists"); */ else { newUser.Username = "******"; break; } } else if (answer.ToLower() == "customer") { break; } else { Utilities.Error("entry"); } } while (trials > 0); #endregion #region Choose Username trials = 3; bool pass = false; do { Console.Write("Username: "******"admin": Console.WriteLine("admin"); pass = true; break; default: newUser.Username = Console.ReadLine(); if (newUser.Username.ToLower() == "admin") { newUser.Username = ""; } else if (pizzaboxRepository.GetUserById(newUser.Username) != null) { Utilities.Error("exists"); } /* * else if (DB.User.Any(u => u.Username == newUser.Username)) * Error("exists"); */ else { pass = true; } break; } if (newUser.Username.Length == 0) { Utilities.Error("user"); } } while (!pass); #endregion #region Choose Password Console.Write("Password: "******"Full Name: "); newUser.FullName = Console.ReadLine(); #endregion Console.Write("\nGetting your account ready "); #region loading animation Utilities.Loading('.', 3, 3); Console.WriteLine(); #endregion newUser.SessionLive = 1; pizzaboxRepository.AddUser(newUser); return(newUser); }