winget-cli

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

TestGetAllSettingsConfigurationUnitProcessor.cs (2227B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="TestGetAllSettingsConfigurationUnitProcessor.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     /// <summary>
     10     /// A test implementation of IConfigurationProcessorFactory.
     11     /// </summary>
     12     internal partial class TestGetAllSettingsConfigurationUnitProcessor : TestConfigurationUnitProcessor, IGetAllSettingsConfigurationUnitProcessor
     13     {
     14         /// <summary>
     15         /// Initializes a new instance of the <see cref="TestGetAllSettingsConfigurationUnitProcessor"/> class.
     16         /// </summary>
     17         /// <param name="unit">The unit.</param>
     18         internal TestGetAllSettingsConfigurationUnitProcessor(ConfigurationUnit unit)
     19             : base(unit)
     20         {
     21         }
     22 
     23         /// <summary>
     24         /// The delegate for GetAllSettings.
     25         /// </summary>
     26         /// <returns>The result.</returns>
     27         internal delegate IGetAllSettingsResult GetAllSettingsDelegateType();
     28 
     29         /// <summary>
     30         /// Gets or sets the delegate object for GetAllSettings.
     31         /// </summary>
     32         internal GetAllSettingsDelegateType? GetAllSettingsDelegate { get; set; }
     33 
     34         /// <summary>
     35         /// Gets the number of times GetAllSettings is called.
     36         /// </summary>
     37         internal int GetAllSettingsCalls { get; private set; } = 0;
     38 
     39         /// <summary>
     40         /// Calls the GetAllSettingsDelegate if one is provided; returns success if not (with no settings values).
     41         /// </summary>
     42         /// <returns>The result.</returns>
     43         public IGetAllSettingsResult GetAllSettings()
     44         {
     45             ++this.GetAllSettingsCalls;
     46             if (this.GetAllSettingsDelegate != null)
     47             {
     48                 return this.GetAllSettingsDelegate();
     49             }
     50             else
     51             {
     52                 return new GetAllSettingsResultInstance(this.Unit);
     53             }
     54         }
     55     }
     56 }