winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

TestDSCv3.cs (6273B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="TestDSCv3.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.Management.Configuration.UnitTests.Helpers
      8 {
      9     using System.Collections.Generic;
     10     using Microsoft.Management.Configuration.Processor.DSCv3.Helpers;
     11     using Microsoft.Management.Configuration.Processor.DSCv3.Model;
     12     using Microsoft.Management.Configuration.Processor.Helpers;
     13 
     14     /// <summary>
     15     /// Implements IDSCv3 for tests.
     16     /// </summary>
     17     internal class TestDSCv3 : IDSCv3
     18     {
     19         /// <summary>
     20         /// The delegate type for GetResourceByType.
     21         /// </summary>
     22         /// <param name="resourceType">The type name of the resource.</param>
     23         /// <returns>A single resource item.</returns>
     24         internal delegate IResourceListItem? GetResourceByTypeDelegateType(string resourceType);
     25 
     26         /// <summary>
     27         /// The delegate type for GetResourceSettings.
     28         /// </summary>
     29         /// <param name="unitInternal">The unit to get.</param>
     30         /// <returns>A get result.</returns>
     31         internal delegate IResourceGetItem GetResourceSettingsDelegateType(ConfigurationUnitInternal unitInternal);
     32 
     33         /// <summary>
     34         /// The delegate type for SetResourceSettings.
     35         /// </summary>
     36         /// <param name="unitInternal">The unit to set.</param>
     37         /// <returns>A set result.</returns>
     38         internal delegate IResourceSetItem SetResourceSettingsDelegateType(ConfigurationUnitInternal unitInternal);
     39 
     40         /// <summary>
     41         /// The delegate type for TestResource.
     42         /// </summary>
     43         /// <param name="unitInternal">The unit to test.</param>
     44         /// <returns>A test result.</returns>
     45         internal delegate IResourceTestItem TestResourceDelegateType(ConfigurationUnitInternal unitInternal);
     46 
     47         /// <summary>
     48         /// The delegate type for TestResource.
     49         /// </summary>
     50         /// <param name="unitInternal">The unit to test.</param>
     51         /// <returns>A test result.</returns>
     52         internal delegate IList<IResourceExportItem> ExportResourceDelegateType(ConfigurationUnitInternal unitInternal);
     53 
     54         /// <summary>
     55         /// Gets or sets the GetResourceByType result.
     56         /// </summary>
     57         public IResourceListItem? GetResourceByTypeResult { get; set; }
     58 
     59         /// <summary>
     60         /// Gets or sets the GetResourceByType delegate.
     61         /// </summary>
     62         public GetResourceByTypeDelegateType? GetResourceByTypeDelegate { get; set; }
     63 
     64         /// <summary>
     65         /// Gets or sets the GetResourceSettings result.
     66         /// </summary>
     67         public IResourceGetItem? GetResourceSettingsResult { get; set; }
     68 
     69         /// <summary>
     70         /// Gets or sets the GetResourceSettings delegate.
     71         /// </summary>
     72         public GetResourceSettingsDelegateType? GetResourceSettingsDelegate { get; set; }
     73 
     74         /// <summary>
     75         /// Gets or sets the SetResourceSettings result.
     76         /// </summary>
     77         public IResourceSetItem? SetResourceSettingsResult { get; set; }
     78 
     79         /// <summary>
     80         /// Gets or sets the SetResourceSettings delegate.
     81         /// </summary>
     82         public SetResourceSettingsDelegateType? SetResourceSettingsDelegate { get; set; }
     83 
     84         /// <summary>
     85         /// Gets or sets the TestResource result.
     86         /// </summary>
     87         public IResourceTestItem? TestResourceResult { get; set; }
     88 
     89         /// <summary>
     90         /// Gets or sets the TestResource delegate.
     91         /// </summary>
     92         public TestResourceDelegateType? TestResourceDelegate { get; set; }
     93 
     94         /// <summary>
     95         /// Gets or sets the ExportResource result.
     96         /// </summary>
     97         public IList<IResourceExportItem>? ExportResourceResult { get; set; }
     98 
     99         /// <summary>
    100         /// Gets or sets the ExportResource delegate.
    101         /// </summary>
    102         public ExportResourceDelegateType? ExportResourceDelegate { get; set; }
    103 
    104         /// <summary>
    105         /// Gets or sets the GetAllResources result.
    106         /// </summary>
    107         public List<IResourceListItem>? GetAllResourcesResult { get; set; }
    108 
    109         /// <inheritdoc/>
    110         public IResourceListItem? GetResourceByType(string resourceType, ProcessorRunSettings? runSettings)
    111         {
    112             return this.GetResourceByTypeResult ?? this.GetResourceByTypeDelegate?.Invoke(resourceType);
    113         }
    114 
    115         /// <inheritdoc/>
    116         public IResourceGetItem GetResourceSettings(ConfigurationUnitInternal unitInternal, ProcessorRunSettings? runSettings)
    117         {
    118             return this.GetResourceSettingsResult ?? this.GetResourceSettingsDelegate?.Invoke(unitInternal) ?? throw new System.NotImplementedException();
    119         }
    120 
    121         /// <inheritdoc/>
    122         public IResourceSetItem SetResourceSettings(ConfigurationUnitInternal unitInternal, ProcessorRunSettings? runSettings)
    123         {
    124             return this.SetResourceSettingsResult ?? this.SetResourceSettingsDelegate?.Invoke(unitInternal) ?? throw new System.NotImplementedException();
    125         }
    126 
    127         /// <inheritdoc/>
    128         public IResourceTestItem TestResource(ConfigurationUnitInternal unitInternal, ProcessorRunSettings? runSettings)
    129         {
    130             return this.TestResourceResult ?? this.TestResourceDelegate?.Invoke(unitInternal) ?? throw new System.NotImplementedException();
    131         }
    132 
    133         /// <inheritdoc/>
    134         public IList<IResourceExportItem> ExportResource(ConfigurationUnitInternal unitInternal, ProcessorRunSettings? runSettings)
    135         {
    136             return this.ExportResourceResult ?? this.ExportResourceDelegate?.Invoke(unitInternal) ?? throw new System.NotImplementedException();
    137         }
    138 
    139         /// <inheritdoc/>
    140         public List<IResourceListItem> GetAllResources(ProcessorRunSettings? runSettings)
    141         {
    142             return this.GetAllResourcesResult ?? throw new System.NotImplementedException();
    143         }
    144     }
    145 }