diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-15 21:41:47 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-16 16:49:44 +1000 |
| commit | 8bcb8c013a258691d4004c50af4689b90dd05c45 (patch) | |
| tree | c79af1f50a94bb8554672a7de231ab35f5e5ddf1 /src/test/BurnUnitTest/CacheTest.cpp | |
| parent | a49441dfa8f9f796d98ce240ffb839b325908498 (diff) | |
| download | wix-8bcb8c013a258691d4004c50af4689b90dd05c45.tar.gz wix-8bcb8c013a258691d4004c50af4689b90dd05c45.tar.bz2 wix-8bcb8c013a258691d4004c50af4689b90dd05c45.zip | |
Import BurnUnitTest from old wix4 repo.
Diffstat (limited to 'src/test/BurnUnitTest/CacheTest.cpp')
| -rw-r--r-- | src/test/BurnUnitTest/CacheTest.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test/BurnUnitTest/CacheTest.cpp b/src/test/BurnUnitTest/CacheTest.cpp new file mode 100644 index 00000000..9b3c6e64 --- /dev/null +++ b/src/test/BurnUnitTest/CacheTest.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | |||
| 6 | namespace Microsoft | ||
| 7 | { | ||
| 8 | namespace Tools | ||
| 9 | { | ||
| 10 | namespace WindowsInstallerXml | ||
| 11 | { | ||
| 12 | namespace Test | ||
| 13 | { | ||
| 14 | namespace Bootstrapper | ||
| 15 | { | ||
| 16 | using namespace System; | ||
| 17 | using namespace System::IO; | ||
| 18 | using namespace WixTest; | ||
| 19 | using namespace Xunit; | ||
| 20 | |||
| 21 | public ref class CacheTest : BurnUnitTest | ||
| 22 | { | ||
| 23 | public: | ||
| 24 | [NamedFact] | ||
| 25 | void CacheSignatureTest() | ||
| 26 | { | ||
| 27 | HRESULT hr = S_OK; | ||
| 28 | BURN_PACKAGE package = { }; | ||
| 29 | BURN_PAYLOAD payload = { }; | ||
| 30 | LPWSTR sczPayloadPath = NULL; | ||
| 31 | BYTE* pb = NULL; | ||
| 32 | DWORD cb = NULL; | ||
| 33 | |||
| 34 | try | ||
| 35 | { | ||
| 36 | pin_ptr<const wchar_t> dataDirectory = PtrToStringChars(TestContext->DataDirectory); | ||
| 37 | hr = PathConcat(dataDirectory, L"BurnTestPayloads\\Products\\TestExe\\TestExe.exe", &sczPayloadPath); | ||
| 38 | Assert::True(S_OK == hr, "Failed to get path to test file."); | ||
| 39 | Assert::True(FileExistsEx(sczPayloadPath, NULL), "Test file does not exist."); | ||
| 40 | |||
| 41 | hr = StrAllocHexDecode(L"232BD16B78C1926F95D637731E1EE5379A3C4222", &pb, &cb); | ||
| 42 | Assert::Equal(S_OK, hr); | ||
| 43 | |||
| 44 | package.fPerMachine = FALSE; | ||
| 45 | package.sczCacheId = L"Bootstrapper.CacheTest.CacheSignatureTest"; | ||
| 46 | payload.sczKey = L"CacheSignatureTest.PayloadKey"; | ||
| 47 | payload.sczFilePath = L"CacheSignatureTest.File"; | ||
| 48 | payload.pbHash = pb; | ||
| 49 | payload.cbHash = cb; | ||
| 50 | |||
| 51 | hr = CacheCompletePayload(package.fPerMachine, &payload, package.sczCacheId, sczPayloadPath, FALSE); | ||
| 52 | Assert::Equal(S_OK, hr); | ||
| 53 | } | ||
| 54 | finally | ||
| 55 | { | ||
| 56 | ReleaseMem(pb); | ||
| 57 | ReleaseStr(sczPayloadPath); | ||
| 58 | |||
| 59 | String^ filePath = Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), "Package Cache\\Bootstrapper.CacheTest.CacheSignatureTest\\CacheSignatureTest.File"); | ||
| 60 | if (File::Exists(filePath)) | ||
| 61 | { | ||
| 62 | File::SetAttributes(filePath, FileAttributes::Normal); | ||
| 63 | File::Delete(filePath); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||
