Resources.cpp (1821B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "TestCommon.h" 5 #include <AppInstallerStrings.h> 6 #include <ChannelStreams.h> 7 #include <ExecutionReporter.h> 8 9 using namespace std::string_view_literals; 10 using namespace AppInstaller::Utility; 11 using namespace AppInstaller::Utility::literals; 12 using namespace AppInstaller::CLI; 13 14 #define WINGET_TEST_OUTPUT_STREAM(_expected_, _input_) \ 15 do { \ 16 std::istringstream iInput; \ 17 std::ostringstream oInput; \ 18 std::istringstream iExpected; \ 19 std::ostringstream oExpected; \ 20 Execution::Reporter(oInput, iInput).Info() << _input_; \ 21 Execution::Reporter(oExpected, iExpected).Info() << _expected_; \ 22 REQUIRE(oExpected.str()== oInput.str()); \ 23 } while(0); 24 25 TEST_CASE("Resources_StringId", "[resources]") 26 { 27 WINGET_TEST_OUTPUT_STREAM( 28 "Filter results by command"_liv, 29 Resource::String::CommandArgumentDescription 30 ); 31 } 32 33 TEST_CASE("Resources_StringIdWithPlaceholders_LocIndString", "[resources]") 34 { 35 WINGET_TEST_OUTPUT_STREAM( 36 "The value provided for the `First` argument is invalid; valid values are: Second"_liv , 37 Resource::String::InvalidArgumentValueError("First"_liv, "Second"_liv) 38 ); 39 } 40 41 TEST_CASE("Resources_StringIdWithPlaceholders_StringId", "[resources]") 42 { 43 WINGET_TEST_OUTPUT_STREAM( 44 "This operation is disabled by Group Policy: Enable Additional Windows App Installer Sources"_liv , 45 Resource::String::DisabledByGroupPolicy(AppInstaller::StringResource::String::PolicyAdditionalSources) 46 ); 47 } 48 49 TEST_CASE("Resources_StringIdWithPlaceholders_Arithmetic", "[resources]") 50 { 51 WINGET_TEST_OUTPUT_STREAM( 52 "42 upgrades available."_liv , 53 Resource::String::AvailableUpgrades(42) 54 ); 55 }