< Summary

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

Metrics

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

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Collections;
 4using System.Diagnostics.Contracts;
 5using System.Linq;
 6using UnityEngine;
 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<Threat> threats);
 27
 28  // Get the list of assignable interceptors.
 29  [Pure]
 30  public static List<Interceptor> GetAssignableInterceptors(
 031      in IReadOnlyList<Interceptor> interceptors) {
 032    return interceptors
 033        .Where(interceptor => interceptor.IsAssignable() && !interceptor.IsTerminated())
 34        .ToList();
 035  }
 36
 37  // Get the list of active threats.
 38  [Pure]
 039  public static List<Threat> GetActiveThreats(in IReadOnlyList<Threat> threats) {
 040    return threats.Where(threat => !threat.IsTerminated()).ToList();
 041  }
 42}