From 7f642e51670bc38a4ef782a363936850bc2b0ba9 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 06:38:23 -0700 Subject: Move dutil into libs/dutil --- src/test/DUtilUnitTest/DirUtilTests.cpp | 70 --------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/test/DUtilUnitTest/DirUtilTests.cpp (limited to 'src/test/DUtilUnitTest/DirUtilTests.cpp') diff --git a/src/test/DUtilUnitTest/DirUtilTests.cpp b/src/test/DUtilUnitTest/DirUtilTests.cpp deleted file mode 100644 index 7643366f..00000000 --- a/src/test/DUtilUnitTest/DirUtilTests.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// 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. - -#include "precomp.h" - -using namespace System; -using namespace Xunit; -using namespace WixBuildTools::TestSupport; - -namespace DutilTests -{ - public ref class DirUtil - { - public: - [Fact] - void DirUtilTest() - { - HRESULT hr = S_OK; - LPWSTR sczCurrentDir = NULL; - LPWSTR sczGuid = NULL; - LPWSTR sczFolder = NULL; - LPWSTR sczSubFolder = NULL; - - try - { - hr = GuidCreate(&sczGuid); - NativeAssert::Succeeded(hr, "Failed to create guid."); - - hr = DirGetCurrent(&sczCurrentDir); - NativeAssert::Succeeded(hr, "Failed to get current directory."); - - hr = PathConcat(sczCurrentDir, sczGuid, &sczFolder); - NativeAssert::Succeeded(hr, "Failed to combine current directory: '{0}' with Guid: '{1}'", sczCurrentDir, sczGuid); - - BOOL fExists = DirExists(sczFolder, NULL); - Assert::False(fExists == TRUE); - - hr = PathConcat(sczFolder, L"foo", &sczSubFolder); - NativeAssert::Succeeded(hr, "Failed to combine folder: '%ls' with subfolder: 'foo'", sczFolder); - - hr = DirEnsureExists(sczSubFolder, NULL); - NativeAssert::Succeeded(hr, "Failed to create multiple directories: %ls", sczSubFolder); - - // Test failure to delete non-empty folder. - hr = DirEnsureDelete(sczFolder, FALSE, FALSE); - Assert::Equal(HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY), hr); - - hr = DirEnsureDelete(sczSubFolder, FALSE, FALSE); - NativeAssert::Succeeded(hr, "Failed to delete single directory: %ls", sczSubFolder); - - // Put the directory back and we'll test deleting tree. - hr = DirEnsureExists(sczSubFolder, NULL); - NativeAssert::Succeeded(hr, "Failed to create single directory: %ls", sczSubFolder); - - hr = DirEnsureDelete(sczFolder, FALSE, TRUE); - NativeAssert::Succeeded(hr, "Failed to delete directory tree: %ls", sczFolder); - - // Finally, try to create "C:\" which would normally fail, but we want success - hr = DirEnsureExists(L"C:\\", NULL); - NativeAssert::Succeeded(hr, "Failed to create C:\\"); - } - finally - { - ReleaseStr(sczSubFolder); - ReleaseStr(sczFolder); - ReleaseStr(sczGuid); - ReleaseStr(sczCurrentDir); - } - } - }; -} -- cgit v1.2.3-55-g6feb