public void TestSimpleTaskSearch() { //Arrange ISearchRepository repository = new SearchRepository(); User u = new User(); u.Username = "******"; u.Password = "******"; Project p = new Project(); p.Name = "Testprojekt"; p.Owner = u; Task t1 = new Task(); t1.Title = "Schreiben des Rhbs"; t1.Project = p; Task t2 = new Task(); t2.Title = "Dialog implementieren"; t2.Project = p; Task t3 = new Task(); t3.Title = "Schreiben von Unit test"; t3.Project = p; p.ProductBacklog.Add(t1); p.ProductBacklog.Add(t2); p.ProductBacklog.Add(t3); IProjectRepository projectRepository = new ProjectRepository(); projectRepository.SaveOrUpdate(p); //Act IList result = repository.Search("Title:Schreiben*"); //Assert Assert.AreEqual(2, result.Count); }
public IList<Project> GetProjectsByOwner(User user) { if(user == null) throw new ArgumentNullException("user"); IList<Project> projects; ISession session = PersistenceManager.CurrentSession; using(ITransaction trans = session.BeginTransaction()) { projects = session.CreateQuery("FROM Project p WHERE p.Owner = :pOwner").SetEntity("pOwner", user).List<Project>(); trans.Commit(); } return projects; }
public User CreateUser(string strUsername, string strPassword, string strEMail) { if(string.IsNullOrEmpty(strUsername)) throw new ArgumentNullException("strUsername"); if(string.IsNullOrEmpty(strPassword)) throw new ArgumentNullException("strPassword"); User user = this.UserRepository.GetByUsername(strUsername); if(user != null) throw new Exception("Username ist bereits vergeben."); user = new User { Username = strUsername, Password = this.EncodePassword(strPassword) }; if(!string.IsNullOrEmpty(strEMail)) user.EMail = strEMail; this.UserRepository.SaveOrUpdate(user); return user; }
public void TestCreate() { // Arrange ProjectRepository repository = new ProjectRepository(); Project p = new Project(); p.Name = "Testprojekt für Unit-Test"; User u = new User(); u.Firstname = "Hans"; u.Lastname = "Muster"; u.Username = "******"; u.EMail = "*****@*****.**"; u.Password = "******"; p.Owner = u; p.Members.Add(u); Task t1 = new Task(); t1.Title = "Task 1"; t1.Project = p; Task t2 = new Task(); t2.Title = "Task 2"; t2.Project = p; Task t3 = new Task(); t3.Title = "Task 3"; t3.Project = p; p.ProductBacklog.Add(t1); p.ProductBacklog.Add(t2); p.ProductBacklog.Add(t3); // Act repository.SaveOrUpdate(p); // Assert Project p2 = repository.GetProject(p.Id); p2 = repository.LoadProductBacklog(p2); Assert.IsNotNull(p2); Assert.AreEqual(p.Name, p2.Name); Assert.AreEqual(p2.Owner.Username, u.Username); Assert.AreEqual(1, p2.Members.Count); Assert.AreEqual(3, p2.ProductBacklog.Count); }
public void TestAdd() { // Arrange IUserRepository repository = new UserRepository(); User u = new User { Username = "******", Password = "******", Firstname = "Hans", Lastname = "Muster", EMail = "*****@*****.**" }; // Act repository.SaveOrUpdate(u); // Assert User user = repository.GetByUsername(u.Username); Assert.IsNotNull(user); Assert.AreEqual(u.Username, user.Username); Assert.AreEqual(u.Firstname, user.Firstname); Assert.AreEqual(u.Lastname, user.Lastname); Assert.AreEqual(u.EMail, user.EMail); }
public IList<Project> GetProjectsByOwner(User user) { throw new NotImplementedException(); }
private bool IsPasswordValid(User user, string strPassword) { if(string.IsNullOrEmpty(strPassword)) throw new ArgumentNullException("strPassword"); return user.Password == EncodePassword(strPassword); }