public void TestUserMethods() { PasswordHelper passHelper = new PasswordHelper("Abcd!234"); StockGameDAL _dal = new StockGameDAL(_connectionString); // Test add user UserItem item = new UserItem(); item.FirstName = "Chris"; item.LastName = "Rupp"; item.Username = "******"; item.Hash = passHelper.Hash; item.Salt = passHelper.Salt; item.Email = "*****@*****.**"; item.RoleId = (int)RoleManager.eRole.Player; int id = _dal.AddUserItem(item); Assert.AreNotEqual(0, id); UserItem itemGet = _dal.GetUserItem(id); Assert.AreEqual(item.Id, itemGet.Id); Assert.AreEqual(item.FirstName, itemGet.FirstName); Assert.AreEqual(item.LastName, itemGet.LastName); Assert.AreEqual(item.Username, itemGet.Username); Assert.AreEqual(item.Hash, itemGet.Hash); Assert.AreEqual(item.Salt, itemGet.Salt); Assert.AreEqual(item.Email, itemGet.Email); // Test update user item.FirstName = "What"; item.LastName = "What"; item.Username = "******"; item.Email = "What"; item.Hash = "What"; item.Salt = "What"; Assert.IsTrue(_dal.UpdateUserItem(item)); itemGet = _dal.GetUserItem(id); Assert.AreEqual(item.Id, itemGet.Id); Assert.AreEqual(item.FirstName, itemGet.FirstName); Assert.AreEqual(item.LastName, itemGet.LastName); Assert.AreEqual(item.Username, itemGet.Username); Assert.AreEqual(item.Hash, itemGet.Hash); Assert.AreEqual(item.Salt, itemGet.Salt); Assert.AreEqual(item.Email, itemGet.Email); // Test delete user _dal.DeleteUserItem(id); var users = _dal.GetUserItems(); foreach (var user in users) { Assert.AreNotEqual(id, user.Id); } }
public void UpdateStocks() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); //Act bool test = _dal.UpdateStocks(); //Assert Assert.IsTrue(test); }
public void AvailableStocks() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); //Act List <Stock> test = _dal.AvailableStocks(); //Assert Assert.IsNotNull(test); }
public void GetCashAmounts() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); //Act List <UserCash> test = _dal.GetCashAmounts(); //Assert Assert.IsNotNull(test); }
public void GetUserIdByUsername() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); string username = "******"; //Act int test = _dal.GetUserIdByUsername(username); //Assert Assert.AreEqual(_userId2, test); }
public void UsersPlaying() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); int gameId = 3; //Act List <UserItem> test = _dal.UsersPlaying(gameId); //Assert Assert.IsNotNull(test); }
public void UserStocks() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); //int userId = 1; int userId = _userId2; //Act List <UserStockItem> test = _dal.UserStocks(userId); //Assert Assert.IsNotNull(test); }
public void SellStock() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); //int userId = 1; int userId = _userId2; int stockId = 1; int shares = 1; //Act bool test = _dal.SellStock(userId, stockId, shares); //Assert Assert.IsTrue(test); }
public void NewGame() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); Game game = new Game() { TimeStarted = DateTime.Now, Duration = 10 }; //Act int test = _dal.NewGame(game); //Assert Assert.IsNotNull(test); }
public void Initialize() { _tran = new TransactionScope(); StockGameDAL _dal = new StockGameDAL(_connectionString); PasswordHelper passHelper = new PasswordHelper("Abcd!234"); if (_userId1 == -1) { var temp = new UserItem() { Id = -1 }; temp.FirstName = "Amy"; temp.LastName = "Rupp"; temp.Username = "******"; temp.Hash = passHelper.Hash; temp.Salt = passHelper.Salt; temp.Email = "*****@*****.**"; temp.RoleId = (int)RoleManager.eRole.Player; // Add user item _userId1 = _dal.AddUserItem(temp); Assert.AreNotEqual(0, _userId1); } if (_userId2 == -1) { var temp = new UserItem() { Id = -1 }; temp.FirstName = "Chloe"; temp.LastName = "Rupp"; temp.Username = "******"; temp.Hash = passHelper.Hash; temp.Salt = passHelper.Salt; temp.Email = "*****@*****.**"; temp.RoleId = (int)RoleManager.eRole.Player; // Add user item _userId2 = _dal.AddUserItem(temp); Assert.AreNotEqual(0, _userId2); } }
public void AddUserGame() { //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); Game game = new Game() { TimeStarted = DateTime.Now, Duration = 10 }; int _gameId = _dal.NewGame(game); //int userId = 9; int userId = _userId2; //int gameId = 2; int gameId = _gameId; //Act bool test = _dal.AddUserGame(userId); //Assert Assert.IsTrue(test); }
public void WipeUserGame() { //Lucas - works if data is in database //Arrange StockGameDAL _dal = new StockGameDAL(_connectionString); int userId = _userId2; Game game = new Game() { TimeStarted = DateTime.Now, Duration = 10 }; int _gameId = _dal.NewGame(game); _dal.AddUserGame(userId); //int gameId = 2; //Act bool test = _dal.WipeUserGame(_gameId); //Assert Assert.IsTrue(test); }