NuDeploy.Core.Services.Packaging.Configuration.PrePackagingFolderPathProvider.GetPrePackagingFolderPath C# (CSharp) Method

GetPrePackagingFolderPath() public method

public GetPrePackagingFolderPath ( ) : string
return string
        public string GetPrePackagingFolderPath()
        {
            string prePackagingFolder = this.applicationInformation.PrePackagingFolder;

            // create folder if it does not exist
            if (this.filesystemAccessor.DirectoryExists(prePackagingFolder) == false)
            {
                this.filesystemAccessor.CreateDirectory(prePackagingFolder);
                return prePackagingFolder;
            }

            // cleanup existing folder
            if (this.filesystemAccessor.DeleteDirectory(prePackagingFolder))
            {
                this.filesystemAccessor.CreateDirectory(prePackagingFolder);
                return prePackagingFolder;
            }

            return prePackagingFolder;
        }

Usage Example

        public void GetPrePackagingFolderPath_DirectoryExistsIsCalled()
        {
            // Arrange
            bool directoryExistsGotCalled = false;

            var applicationInformation = ApplicationInformationProvider.GetApplicationInformation();

            var filesystemAccessorMock = new Mock<IFilesystemAccessor>();
            filesystemAccessorMock.Setup(f => f.DirectoryExists(applicationInformation.PrePackagingFolder)).Returns(
                () =>
                    {
                        directoryExistsGotCalled = true;
                        return true;
                    });

            var prePackagingFolderPathProvider = new PrePackagingFolderPathProvider(applicationInformation, filesystemAccessorMock.Object);

            // Act
            prePackagingFolderPathProvider.GetPrePackagingFolderPath();

            // Assert
            Assert.IsTrue(directoryExistsGotCalled);
        }
All Usage Examples Of NuDeploy.Core.Services.Packaging.Configuration.PrePackagingFolderPathProvider::GetPrePackagingFolderPath