< Summary

Class:MUNity.Database.FluentAPI.ProjectOptionsBuilder
Assembly:MUNity.Database
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\FluentAPI\Project\ProjectOptionsBuilder.cs
Covered lines:33
Uncovered lines:1
Coverable lines:34
Total lines:61
Line coverage:97% (33 of 34)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)
Covered methods:7
Total methods:7
Method coverage:100% (7 of 7)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Project()100%1100%
.ctor(...)100%1100%
WithName(...)100%1100%
WithShort(...)100%1100%
WithCreationUser(...)100%1100%
WithOrganization(...)50%285.71%
WithConference(...)100%1100%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\FluentAPI\Project\ProjectOptionsBuilder.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using MUNity.Database.Context;
 4using MUNity.Database.Models.Conference;
 5using MUNity.Database.Models.Organization;
 6using MUNity.Database.Models.User;
 7
 8namespace MUNity.Database.FluentAPI;
 9
 10public class ProjectOptionsBuilder
 11{
 2012    public Project Project { get; }
 13
 14    private readonly MunityContext _context;
 15
 416    private bool _useEasyId = true;
 17
 18    public ProjectOptionsBuilder WithName(string name)
 419    {
 420        this.Project.ProjectName = name;
 421        return this;
 422    }
 23
 24    public ProjectOptionsBuilder WithShort(string shortName)
 425    {
 426        this.Project.ProjectShort = shortName;
 427        return this;
 428    }
 29
 30    public ProjectOptionsBuilder WithCreationUser(MunityUser user)
 131    {
 132        this.Project.CreationUser = user;
 133        return this;
 134    }
 35
 36    public ProjectOptionsBuilder WithOrganization(string organizationId)
 137    {
 138        var organization = _context.Organizations.FirstOrDefault(n => n.OrganizationId == organizationId);
 139        if (organization == null)
 040            throw new NullReferenceException("The Organization with the given Id cannot be found!");
 41
 142        Project.ProjectOrganization = organization;
 143        return this;
 144    }
 45
 46    public ProjectOptionsBuilder WithConference(Action<ConferenceOptionsBuilder> options)
 247    {
 248        var builder = new ConferenceOptionsBuilder(_context, Project);
 249        options(builder);
 250        var conference = builder.Conference;
 251        _context.Conferences.Add(conference);
 252        return this;
 253    }
 54
 455    public ProjectOptionsBuilder(MunityContext context, Organization organization = null)
 456    {
 457        this.Project = new Project();
 458        this._context = context;
 459        this.Project.ProjectOrganization = organization;
 460    }
 61}