< Summary

Information
Class: CounterDrone.Core.Services.GroupService
Assembly: CounterDrone.Core
File(s): C:\Users\Tellme\apps\CounterDroneBackend\src\CounterDrone.Core\Services\GroupService.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 50
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CreateGroup(...)100%22100%
DeleteGroup(...)100%11100%
GetGroups(...)100%22100%
GetGroup(...)100%11100%

File(s)

C:\Users\Tellme\apps\CounterDroneBackend\src\CounterDrone.Core\Services\GroupService.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using CounterDrone.Core.Models;
 4using CounterDrone.Core.Repository;
 5
 6namespace CounterDrone.Core.Services
 7{
 8    public class GroupService : IGroupService
 9    {
 10        private readonly GroupRepository _repo;
 11
 512        public GroupService(GroupRepository repo)
 513        {
 514            _repo = repo;
 515        }
 16
 17        public Group CreateGroup(string name, GroupType type, string description)
 718        {
 719            if (string.IsNullOrWhiteSpace(name))
 120                throw new ArgumentException("编组名称不能为空");
 21
 622            var group = new Group
 623            {
 624                Name = name,
 625                GroupType = (int)type,
 626                Description = description,
 627            };
 28
 629            _repo.Insert(group);
 630            return group;
 631        }
 32
 33        public void DeleteGroup(string id)
 134        {
 135            _repo.Delete(id);
 136        }
 37
 38        public List<Group> GetGroups(GroupType? type)
 239        {
 240            if (type.HasValue)
 141                return _repo.GetByType((int)type.Value);
 142            return _repo.GetAll();
 243        }
 44
 45        public Group GetGroup(string id)
 246        {
 247            return _repo.GetById(id);
 248        }
 49    }
 50}