Commit 0477314e authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix Test TearDown

parent 71814de0
...@@ -23,6 +23,7 @@ namespace Coscine.Api.Project.Tests ...@@ -23,6 +23,7 @@ namespace Coscine.Api.Project.Tests
private List<Coscine.Database.Model.Project> projects = new List<Coscine.Database.Model.Project>(); private List<Coscine.Database.Model.Project> projects = new List<Coscine.Database.Model.Project>();
private List<User> users = new List<User>(); private List<User> users = new List<User>();
private List<ProjectRole> projectRoles = new List<ProjectRole>();
private int previous; private int previous;
...@@ -69,7 +70,9 @@ namespace Coscine.Api.Project.Tests ...@@ -69,7 +70,9 @@ namespace Coscine.Api.Project.Tests
}; };
projectModel.Insert(project); projectModel.Insert(project);
projectModel.SetOwner(project, user); var projectRole = projectModel.SetOwner(project, user);
projectRoles.Add(projectRole);
projects.Add(projectModel.GetById(project.Id)); projects.Add(projectModel.GetById(project.Id));
var project2 = new Coscine.Database.Model.Project() var project2 = new Coscine.Database.Model.Project()
...@@ -85,6 +88,11 @@ namespace Coscine.Api.Project.Tests ...@@ -85,6 +88,11 @@ namespace Coscine.Api.Project.Tests
[OneTimeTearDown] [OneTimeTearDown]
public void End() public void End()
{ {
ProjectRoleModel projectRoleModel = new ProjectRoleModel();
foreach (var projectRole in projectRoles)
{
projectRoleModel.Delete(projectRole);
}
ProjectModel projectModel = new ProjectModel(); ProjectModel projectModel = new ProjectModel();
foreach (var project in projects) foreach (var project in projects)
{ {
......
...@@ -31,7 +31,7 @@ namespace Coscine.Api.Project.Models ...@@ -31,7 +31,7 @@ namespace Coscine.Api.Project.Models
return project; return project;
} }
public void SetOwner(Coscine.Database.Model.Project project, User user) public ProjectRole SetOwner(Coscine.Database.Model.Project project, User user)
{ {
ProjectRoleModel projectRoleModel = new ProjectRoleModel(); ProjectRoleModel projectRoleModel = new ProjectRoleModel();
...@@ -43,6 +43,8 @@ namespace Coscine.Api.Project.Models ...@@ -43,6 +43,8 @@ namespace Coscine.Api.Project.Models
RoleId = new RoleModel().GetWhere((x) => x.DisplayName == "Owner").Id RoleId = new RoleModel().GetWhere((x) => x.DisplayName == "Owner").Id
}; };
projectRoleModel.Insert(projectRole); projectRoleModel.Insert(projectRole);
return projectRole;
} }
public bool OwnsProject(User user, Coscine.Database.Model.Project project) public bool OwnsProject(User user, Coscine.Database.Model.Project project)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment