< Summary

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

Metrics

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

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
 517    public AssignmentItem(Interceptor interceptor, Threat threat) {
 518      Interceptor = interceptor;
 519      Threat = threat;
 520    }
 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(
 231      in IReadOnlyList<Interceptor> interceptors) {
 832    return interceptors.Where(interceptor => interceptor.IsAssignable()).ToList();
 233  }
 34
 35  // Get the list of active threats.
 36  [Pure]
 237  protected static List<ThreatData> GetActiveThreats(in IReadOnlyList<ThreatData> threats) {
 738    return threats.Where(t => t.Status != ThreatStatus.DESTROYED).ToList();
 239  }
 40}