public void AddStreamToCompleteProjectThrowsException()
 {
     var projectManager = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var newProjectStream = new ProjectStream("Stream1", "Create a new stream that takes over the whole project.");
     const string exceptionMessage = "Cannot add stream to project with status of Complete.";
     Assert.That(() => projectManager.AddProjectStream(completedProject.Name, newProjectStream, activeUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void AddStreamToActiveProjectUserNotInProjectThrowsException()
 {
     var projectManager = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var newProjectStream = new ProjectStream("Stream1", "Create a new stream that takes over the whole project.");
     var exceptionMessage = string.Format("User {0} is currently not active in Project {1}.", activeUserNotInProject.Username, activeProject.Name);
     Assert.That(() => projectManager.AddProjectStream(activeProject.Name, newProjectStream, activeUserNotInProject.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void AddNonExistentUserToProjectThrowsException()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     const string userToAdd = "doesntexist";
     var exceptionMessage = string.Format("Could not find UserAccount {0}.", userToAdd);
     Assert.That(() => pm.AddUserToProject(_existingProject.Name, userToAdd, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateProjectGoalWithoutObjectivesThrowsException()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var goal = new Goal("Big New Goal", null, _existingUser.Username);
     const string exceptionMessage = "Goals must contain associated objectives.";
     Assert.That(() => pm.AddGoalToProject(_existingProject.Name, goal, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void AddUserToProject_ProjectNotFoundThrowsException()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     var notExistingProjectName = "notExistingProject";
     string exceptionMessage = string.Format("Could not find Project {0}.", notExistingProjectName);
     Assert.That(() => pm.AddUserToProject(notExistingProjectName, _newActiveUser.Username, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateProjectGoalUserNotInProjectThrowsException()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var objectives = new List<Objective> { new Objective("Dancing", "Do A Dance") };
     var goal = new Goal("Big New Goal", objectives, _existingUserNotInProject.Username);
     const string exceptionMessage = "existingUserNotInProject is not authorised to edit Project existing.";
     Assert.That(() => pm.AddGoalToProject(_existingProject.Name, goal, _existingUserNotInProject.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateProjectGoalProjectNotActiveThrowsException()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var objectives = new List<Objective> { new Objective("Dancing", "Do A Dance") };
     var goal = new Goal("Big New Goal", objectives, _existingUser.Username);
     var exceptionMessage = string.Format("Cannot add stream to project with status of {0}.", _existingProjectNotActive.Status);
     Assert.That(() => pm.AddGoalToProject(_existingProjectNotActive.Name, goal, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateProjectGoalProjectNameNotFoundThrowsException()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var objectives = new List<Objective> { new Objective("Dancing", "Do A Dance") };
     var goal = new Goal("Big New Goal", objectives, _existingUser.Username);
     const string exceptionMessage = "Could not find Project notarealproject.";
     Assert.That(() => pm.AddGoalToProject("notarealproject", goal, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void AddUserToProjectAlreadyExistingSuccess()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     pm.AddUserToProject(_existingProjectWithExtraUser.Name, _existingUserAlreadyAddedToProject.Username, _existingUser.Username);
     var session = _embeddedDocStore.OpenSession();
     var updatedProject = session.Query<Project>().Where(p => p.Name == _existingProjectWithExtraUser.Name).First();
     Assert.IsTrue(updatedProject.Users.Contains(_existingUserAlreadyAddedToProject.Username));
 }
 public void AddUserToProjectSuccess()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     pm.AddUserToProject(_existingProject.Name, _newActiveUser.Username, _existingUser.Username);
     var session = _embeddedDocStore.OpenSession();
     var updatedProject = session.Query<Project>().Where(p => p.Name == _existingProject.Name).First();
     Assert.IsTrue(updatedProject.Users.Contains(_newActiveUser.Username));
 }
 public void CreateNewProjectInactiveUser()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     const string user = "******";
     const string projectName = "project";
     var exceptionMessage = string.Format("Cannot create new project '{0}' - {1} is an inactive user.", projectName, user);
     Assert.That(() => pm.CreateProject(projectName, user), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateNewProjectDuplicateName()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     const string projectName = "existing";
     const string user = "******";
     var exceptionMessage = string.Format("Cannot create new project '{0}' - this project name is already in use.", projectName);
     Assert.That(() => pm.CreateProject(projectName, user), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateUserNotExistingSuccess()
 {
     var projectManager = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     const string newUser = "******";
     projectManager.CreateUserAccount(newUser);
     var session = _embeddedDocStore.OpenSession();
     var userCount = session.Query<UserAccount>().Where(u => u.Username == newUser && u.Status == UserStatus.Active).Count();
     Assert.That(userCount, Is.EqualTo(1));
 }
 public void AddStreamToActiveProjectSuccess()
 {
     var projectManager = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var newProjectStream = new ProjectStream("Stream1", "Create a new stream that takes over the whole project.");
     projectManager.AddProjectStream(activeProject.Name, newProjectStream, activeUser.Username);
     var session = _embeddedDocStore.OpenSession();
     var project = session.Query<Project>().Where(p => p.Name == activeProject.Name).First();
     Assert.That(project.ProjectStreams.Count, Is.EqualTo(1));
     Assert.That(project.ProjectStreams[0].CreatedBy, Is.EqualTo(activeUser.Username));
 }
 public void CreateNewProjectUniqueName()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     const string projectName = "newProject";
     const string user = "******";
     var createdProject = pm.CreateProject(projectName, user);
     Assert.That(createdProject.Owner, Is.EqualTo(user));
     Assert.That(createdProject.Name, Is.EqualTo(projectName));
     AssertProjectIsCreated(projectName, user);
 }
 public void CreateProjectGoalWithObjectivesSuccess()
 {
     var pm = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     var objectives = new List<Objective> { new Objective("Dancing", "Do A Dance") };
     var goal = new Goal("Big New Goal", objectives, _existingUser.Username);
     pm.AddGoalToProject(_existingProject.Name, goal, _existingUser.Username);
     var session = _embeddedDocStore.OpenSession();
     var project = session.Query<Project>().Where(p => p.Name == _existingProject.Name).First();
     Assert.That(project.Goals.Count(), Is.GreaterThan(0));
     Assert.That(project.Goals[0].Status, Is.EqualTo(Status.Active));
     Assert.That(project.Goals[0].CreatedBy, Is.EqualTo(_existingUser.Username));
     Assert.That(project.Goals[0].Objectives.Count(), Is.GreaterThan(0));
     Assert.That(project.Goals[0].Objectives[0].Name, Is.EqualTo(objectives[0].Name));
     Assert.That(project.Goals[0].Objectives[0].Description, Is.EqualTo(objectives[0].Description));
     Assert.That(project.Goals[0].Objectives[0].PercentageComplete, Is.EqualTo(0));
 }
 public void CreateUserAlreadyExistsThrowsException()
 {
     var projectManager = new ProjectManager { Session = _embeddedDocStore.OpenSession() };
     const string newUser = "******";
     Assert.That(() => projectManager.CreateUserAccount(newUser), Throws.ArgumentException.With.Message.EqualTo("User " + newUser + " already exists."));
 }
 public void AddUserToProjectActingUserNotInProjectThrowsException()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     string exceptionMessage = string.Format("{0} is not authorised to add new users to Project {1}.", _notInProjectUser.Username, _existingProject.Name);
     Assert.That(() => pm.AddUserToProject(_existingProject.Name, _newActiveUser.Username, _notInProjectUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void AddInactiveUserToProjectThrowsException()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     var exceptionMessage = string.Format("{0} is not currently an active user, please reactivate and try again", _newInactiveUser.Username);
     Assert.That(() => pm.AddUserToProject(_existingProject.Name, _newInactiveUser.Username, _existingUser.Username), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
 }
 public void CreateNewProjectUniqueName()
 {
     var pm = new ProjectManager { DocumentStore = _embeddedDocStore };
     const string projectName = "newProject";
     var user = new UserAccount();
     var createdProject = pm.CreateProject(projectName, user);
     Assert.That(createdProject.Owner, Is.EqualTo(user.Username));
     Assert.That(createdProject.Name, Is.EqualTo(projectName));
     AssertProjectIsCreated(projectName, user.Username);
 }