public async Task AddUserTwice() { bool result; RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory"); // Seed the test database using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); GlobalModels.User inputGMUser = BusinessLogic.Mapper.RepoUserToUser(dataSetA.User); RepoLogic repoLogic = new RepoLogic(context); // Test CreateUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); await userController.CreateUser(inputGMUser); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); // Test AddUser() result = await repoLogic.AddUser(dataSetA.User); } Assert.False(result); }
public bool AddUser(GlobalModels.User user) { User repoUser = new User(); repoUser.Username = user.Username; repoUser.FirstName = user.Firstname; repoUser.LastName = user.Lastname; repoUser.Email = user.Email; repoUser.Permissions = user.Permissions; _dbContext.Users.Add(repoUser); if (_dbContext.SaveChanges() > 0) { return(true); } return(false); }
public async Task UserTest() { GlobalModels.User updatedGMUser = new GlobalModels.User(); RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory"); updatedGMUser.Username = dataSetA.User.Username; updatedGMUser.Firstname = "Steve"; updatedGMUser.Lastname = dataSetA.User.LastName; updatedGMUser.Email = dataSetA.User.Email; updatedGMUser.Permissions = dataSetA.User.Permissions; updatedGMUser.Username = dataSetA.User.Username; string inputFirstName = dataSetA.User.FirstName; string outputFirstName; // Seed the test database using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); RepoLogic repoLogic = new RepoLogic(context); // Test CreateUser & UpdateUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); await userController.CreateUser(BusinessLogic.Mapper.RepoUserToUser(dataSetA.User)); await userController.UpdateUser(dataSetA.User.Username, updatedGMUser); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); // Test GetUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); outputFirstName = userController.GetUser(dataSetA.User.Username).Value.Firstname; } Assert.NotEqual(inputFirstName, outputFirstName); }