winget-cli

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

TestConfigurationSetResult.cpp (2223B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include "TestConfigurationSetResult.h"
      5 #include "TestConfigurationSetResult.g.cpp"
      6 
      7 namespace winrt::Microsoft::Management::Configuration::implementation
      8 {
      9     TestConfigurationSetResult::TestConfigurationSetResult() : m_unitResults(multi_threaded_vector<TestConfigurationUnitResult>())
     10     {
     11     }
     12 
     13     void TestConfigurationSetResult::AppendUnitResult(const TestConfigurationUnitResult& unitResult)
     14     {
     15         m_unitResults.Append(unitResult);
     16 
     17         // Also aggregate the result of this incoming test into the overall result
     18         m_testResult = FoldInTestResult(m_testResult, unitResult.TestResult());
     19     }
     20 
     21     ConfigurationTestResult TestConfigurationSetResult::FoldInTestResult(ConfigurationTestResult current, ConfigurationTestResult incoming)
     22     {
     23         switch (current)
     24         {
     25         case ConfigurationTestResult::Unknown:
     26         case ConfigurationTestResult::NotRun:
     27             // In these "default" cases, just take the unit result
     28             return incoming;
     29             break;
     30         case ConfigurationTestResult::Positive:
     31             if (incoming == ConfigurationTestResult::Negative || incoming == ConfigurationTestResult::Failed)
     32             {
     33                 return incoming;
     34             }
     35             break;
     36         case ConfigurationTestResult::Negative:
     37             if (incoming == ConfigurationTestResult::Failed)
     38             {
     39                 return incoming;
     40             }
     41             break;
     42         case ConfigurationTestResult::Failed:
     43             // If a unit failed, the set failed
     44             break;
     45         default:
     46             THROW_HR(E_UNEXPECTED);
     47         }
     48 
     49         return current;
     50     }
     51 
     52     Windows::Foundation::Collections::IVectorView<TestConfigurationUnitResult> TestConfigurationSetResult::UnitResults() const
     53     {
     54         return m_unitResults.GetView();
     55     }
     56 
     57     ConfigurationTestResult TestConfigurationSetResult::TestResult() const
     58     {
     59         return m_testResult;
     60     }
     61 
     62     void TestConfigurationSetResult::TestResult(ConfigurationTestResult value)
     63     {
     64         m_testResult = value;
     65     }
     66 }