< Summary

Class:MUNity.Database.FluentAPI.ConferenceOptionsBuilder
Assembly:MUNity.Database
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\FluentAPI\Conference\ConferenceOptionsBuilder.cs
Covered lines:50
Uncovered lines:1
Coverable lines:51
Total lines:90
Line coverage:98% (50 of 51)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)
Covered methods:11
Total methods:11
Method coverage:100% (11 of 11)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Conference()100%1100%
WithName(...)100%1100%
WithFullName(...)100%1100%
WithShort(...)100%1100%
WithStartDate(...)100%1100%
WithEndDate(...)100%1100%
WithBasePrice(...)100%1100%
ByUser(...)100%1100%
WithProject(...)50%285.71%
WithCommittee(...)100%1100%
.ctor(...)100%1100%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\FluentAPI\Conference\ConferenceOptionsBuilder.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using MUNity.Database.Context;
 4using MUNity.Database.Models.Conference;
 5using MUNity.Database.Models.User;
 6
 7namespace MUNity.Database.FluentAPI;
 8
 9public class ConferenceOptionsBuilder
 10{
 11    private Conference _conference;
 12
 13    private readonly MunityContext _context;
 14
 15    public Conference Conference
 16    {
 17        get
 518        {
 519            this._conference.CreationDate = DateTime.Now;
 520            return _conference;
 521        }
 22    }
 23
 24    public ConferenceOptionsBuilder WithName(string name)
 325    {
 326        this._conference.Name = name;
 327        return this;
 328    }
 29
 30    public ConferenceOptionsBuilder WithFullName(string fullName)
 331    {
 332        this._conference.FullName = fullName;
 333        return this;
 334    }
 35
 36    public ConferenceOptionsBuilder WithShort(string shortName)
 337    {
 338        this._conference.ConferenceShort = shortName;
 339        return this;
 340    }
 41
 42    public ConferenceOptionsBuilder WithStartDate(DateTime startDate)
 143    {
 144        this._conference.StartDate = startDate;
 145        return this;
 146    }
 47
 48    public ConferenceOptionsBuilder WithEndDate(DateTime endDate)
 149    {
 150        this._conference.EndDate = endDate;
 151        return this;
 152    }
 53
 54    public ConferenceOptionsBuilder WithBasePrice(decimal price)
 155    {
 156        this._conference.GeneralParticipationCost = price;
 157        return this;
 158    }
 59
 60    public ConferenceOptionsBuilder ByUser(MunityUser user)
 161    {
 162        this._conference.CreationUser = user;
 163        return this;
 164    }
 65
 66    public ConferenceOptionsBuilder WithProject(string projectId)
 167    {
 168        var project = _context.Projects.FirstOrDefault(n => n.ProjectId == projectId);
 169        if (project == null)
 070            throw new NullReferenceException($"The given Project {projectId} was not found. Make sure it exists.");
 71
 172        Conference.ConferenceProject = project;
 173        return this;
 174    }
 75
 76    public ConferenceOptionsBuilder WithCommittee(Action<CommitteeOptionsBuilder> builder)
 177    {
 178        var options = new CommitteeOptionsBuilder();
 179        builder(options);
 180        this._conference.Committees.Add(options.Committee);
 181        return this;
 182    }
 83
 384    public ConferenceOptionsBuilder(MunityContext context, Project project = null)
 385    {
 386        this._conference = new Conference();
 387        this._context = context;
 388        this._conference.ConferenceProject = project;
 389    }
 90}