@@ -1065,6 +1065,71 @@ namespace winrt::Microsoft::Management::Configuration::implementation
10651065 return *result;
10661066 }
10671067
1068+ Configuration::TestConfigurationUnitResult ConfigurationProcessor::TestUnit (const ConfigurationUnit& unit)
1069+ {
1070+ THROW_HR_IF (E_NOT_VALID_STATE, !m_factory);
1071+ return TestUnitImpl (unit);
1072+ }
1073+
1074+ Windows::Foundation::IAsyncOperation<Configuration::TestConfigurationUnitResult> ConfigurationProcessor::TestUnitAsync (const ConfigurationUnit& unit)
1075+ {
1076+ THROW_HR_IF (E_NOT_VALID_STATE, !m_factory);
1077+
1078+ auto strong_this{ get_strong () };
1079+ ConfigurationUnit localUnit = unit;
1080+
1081+ co_await winrt::resume_background ();
1082+
1083+ co_return TestUnitImpl (localUnit, { co_await winrt::get_cancellation_token () });
1084+ }
1085+
1086+ Configuration::TestConfigurationUnitResult ConfigurationProcessor::TestUnitImpl (
1087+ const ConfigurationUnit& unit,
1088+ AppInstaller::WinRT::AsyncCancellation cancellation)
1089+ {
1090+ auto threadGlobals = m_threadGlobals.SetForCurrentThread ();
1091+
1092+ IConfigurationSetProcessor setProcessor = m_factory.CreateSetProcessor (nullptr );
1093+ auto result = make_self<wil::details::module_count_wrapper<implementation::TestConfigurationUnitResult>>();
1094+ auto unitResult = make_self<wil::details::module_count_wrapper<implementation::ConfigurationUnitResultInformation>>();
1095+ result->Unit (unit);
1096+ result->ResultInformation (*unitResult);
1097+
1098+ cancellation.ThrowIfCancelled ();
1099+
1100+ IConfigurationUnitProcessor unitProcessor;
1101+
1102+ try
1103+ {
1104+ unitProcessor = setProcessor.CreateUnitProcessor (unit);
1105+ }
1106+ catch (...)
1107+ {
1108+ ExtractUnitResultInformation (std::current_exception (), unitResult);
1109+ }
1110+
1111+ cancellation.ThrowIfCancelled ();
1112+
1113+ if (unitProcessor)
1114+ {
1115+ try
1116+ {
1117+ auto testResult = unitProcessor.TestSettings ();
1118+ result->Unit (testResult.Unit ());
1119+ result->TestResult (testResult.TestResult ());
1120+ result->ResultInformation (testResult.ResultInformation ());
1121+ }
1122+ catch (...)
1123+ {
1124+ ExtractUnitResultInformation (std::current_exception (), unitResult);
1125+ }
1126+
1127+ m_threadGlobals.GetTelemetryLogger ().LogConfigUnitRunIfAppropriate (GUID_NULL, unit, ConfigurationUnitIntent::Assert, TelemetryTraceLogger::TestAction, result->ResultInformation ());
1128+ }
1129+
1130+ return *result;
1131+ }
1132+
10681133 IConfigurationGroupProcessor ConfigurationProcessor::GetSetGroupProcessor (const Configuration::ConfigurationSet& configurationSet)
10691134 {
10701135 IConfigurationSetProcessor setProcessor = m_factory.CreateSetProcessor (configurationSet);
0 commit comments