< Summary

Class:IAssignment
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Assignment/Assignment.cs
Covered lines:3
Uncovered lines:7
Coverable lines:10
Total lines:40
Line coverage:30% (3 of 10)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:3
Method coverage:33.3% (1 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AssignmentItem(...)0%2100%
GetAssignableInterceptors(...)0%220100%
GetActiveThreats(...)0%6200%

File(s)

/github/workspace/Assets/Scripts/Assignment/Assignment.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Collections;
 4using UnityEngine;
 5using System.Linq;
 6using System.Diagnostics.Contracts;
 7
 8// The assignment class is an interface for assigning a threat to each interceptor.
 9public interface IAssignment {
 10  // Assignment item type.
 11  // The first element corresponds to the interceptor index, and the second element
 12  // corresponds to the threat index.
 13  public struct AssignmentItem {
 14    public Interceptor Interceptor;
 15    public Threat Threat;
 16
 017    public AssignmentItem(Interceptor interceptor, Threat threat) {
 018      Interceptor = interceptor;
 019      Threat = threat;
 020    }
 21  }
 22
 23  // Assign a target to each interceptor that has not been assigned a target yet.
 24  [Pure]
 25  public abstract IEnumerable<AssignmentItem> Assign(in IReadOnlyList<Interceptor> interceptors,
 26                                                     in IReadOnlyList<ThreatData> threatTable);
 27
 28  // Get the list of assignable interceptor indices.
 29  [Pure]
 30  protected static List<Interceptor> GetAssignableInterceptors(
 131      in IReadOnlyList<Interceptor> interceptors) {
 232    return interceptors.Where(interceptor => interceptor.IsAssignable()).ToList();
 133  }
 34
 35  // Get the list of active threats.
 36  [Pure]
 037  protected static List<ThreatData> GetActiveThreats(in IReadOnlyList<ThreatData> threats) {
 038    return threats.Where(t => t.Status != ThreatStatus.DESTROYED).ToList();
 039  }
 40}