| | | 1 | | namespace Envilder; |
| | | 2 | | |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Linq; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// The outcome of checking a map file contract: the map file is valid and |
| | | 8 | | /// every declared secret exists. When the map file is invalid, |
| | | 9 | | /// <see cref="Keys"/> is empty because no provider was called. |
| | | 10 | | /// </summary> |
| | | 11 | | public class ContractValidationResult |
| | | 12 | | { |
| | | 13 | | /// <summary>Initializes a new instance.</summary> |
| | | 14 | | /// <param name="mapFileErrors">Every reason the map file cannot be used.</param> |
| | | 15 | | /// <param name="keys">One check per variable of the map file, in map-file order.</param> |
| | 1 | 16 | | public ContractValidationResult( |
| | 1 | 17 | | IReadOnlyList<MapFileError> mapFileErrors, |
| | 1 | 18 | | IReadOnlyList<KeyCheck> keys) |
| | | 19 | | { |
| | 1 | 20 | | MapFileErrors = mapFileErrors; |
| | 1 | 21 | | Keys = keys; |
| | 1 | 22 | | IsValid = mapFileErrors.Count == 0 |
| | 1 | 23 | | && keys.All(key => key.Status == SecretExistenceStatus.Exists); |
| | 1 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// <see langword="true"/> when the map file has no errors and every key |
| | | 28 | | /// <see cref="SecretExistenceStatus.Exists"/>. |
| | | 29 | | /// </summary> |
| | | 30 | | public bool IsValid { get; } |
| | | 31 | | |
| | | 32 | | /// <summary>Why the map file cannot be used. Empty when it is valid.</summary> |
| | | 33 | | public IReadOnlyList<MapFileError> MapFileErrors { get; } |
| | | 34 | | |
| | | 35 | | /// <summary>One check per variable, in map-file order. Empty when the map file is invalid.</summary> |
| | | 36 | | public IReadOnlyList<KeyCheck> Keys { get; } |
| | | 37 | | } |