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
private List<Coscine.Database.Model.Project> projects = new List<Coscine.Database.Model.Project>();
private List<User> users = new List<User>();
private List<ProjectRole> projectRoles = new List<ProjectRole>();
private int previous;
......@@ -69,7 +70,9 @@ namespace Coscine.Api.Project.Tests
};
projectModel.Insert(project);
projectModel.SetOwner(project, user);
var projectRole = projectModel.SetOwner(project, user);
projectRoles.Add(projectRole);
projects.Add(projectModel.GetById(project.Id));
var project2 = new Coscine.Database.Model.Project()
......@@ -85,6 +88,11 @@ namespace Coscine.Api.Project.Tests
[OneTimeTearDown]
public void End()
{
ProjectRoleModel projectRoleModel = new ProjectRoleModel();
foreach (var projectRole in projectRoles)
{
projectRoleModel.Delete(projectRole);
}
ProjectModel projectModel = new ProjectModel();
foreach (var project in projects)
{
......
......@@ -31,7 +31,7 @@ namespace Coscine.Api.Project.Models
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();
......@@ -43,6 +43,8 @@ namespace Coscine.Api.Project.Models
RoleId = new RoleModel().GetWhere((x) => x.DisplayName == "Owner").Id
};
projectRoleModel.Insert(projectRole);
return projectRole;
}
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