From fb8903d9a185a020d54d2bb001f4331caf7c3825 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 14 Jan 2023 22:05:32 -0600 Subject: Improve test coverage for recent Burn changes. 7068, PR 318 --- src/burn/test/BurnUnitTest/CacheTest.cpp | 2 +- src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/burn/test/BurnUnitTest/CacheTest.cpp b/src/burn/test/BurnUnitTest/CacheTest.cpp index 2bec05fe..8e3660b2 100644 --- a/src/burn/test/BurnUnitTest/CacheTest.cpp +++ b/src/burn/test/BurnUnitTest/CacheTest.cpp @@ -83,7 +83,7 @@ namespace Bootstrapper CacheUninitialize(&cache); // Second fallback is system-level %TMP%. - hr = RegWriteExpandString(hkSystemEnvironment, L"TMP", L"B:\\TEST\\TMP\\"); + hr = RegWriteString(hkSystemEnvironment, L"TMP", L"B:\\TEST\\TMP\\"); NativeAssert::Succeeded(hr, "Failed to write TEMP system environment value."); hr = CacheInitialize(&cache, &internalCommand); diff --git a/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs index d9eb36ba..65d0c9cd 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs @@ -15,6 +15,7 @@ namespace WixToolsetTest.BurnE2E [RuntimeFact] public void AllowsBAToKeepRegistration() { + const string fakeInstallDay = "20230101"; this.CreatePackageInstaller("PackageA"); var bundleA = this.CreateBundleInstaller("BundleA"); var testBAController = this.CreateTestBAController(); @@ -35,6 +36,12 @@ namespace WixToolsetTest.BurnE2E testBAController.SetForceKeepRegistration(null); testBAController.ResetPackageStates("PackageA"); + // Pretend the bundle was installed on this day to be able to verify that it is only written on the initial install. + using (var registrationKey = initialRegistration.BaseKey.OpenSubKey(initialRegistration.KeyPath, writable: true)) + { + registrationKey.SetValue(GenericArpRegistration.REGISTRY_ARP_INSTALL_DATE, fakeInstallDay); + } + bundleA.Install(); var finalRegistration = bundleA.VerifyRegisteredAndInPackageCache(); @@ -42,7 +49,7 @@ namespace WixToolsetTest.BurnE2E Assert.NotNull(finalRegistration.EstimatedSize); Assert.InRange(finalRegistration.EstimatedSize.Value, initialRegistration.EstimatedSize.Value + 1, Int32.MaxValue); - Assert.Equal(initialRegistration.InstallDate, finalRegistration.InstallDate); + Assert.Equal(fakeInstallDay, finalRegistration.InstallDate); } [RuntimeFact] -- cgit v1.2.3-55-g6feb