DeleteFile() 공개 메소드

public DeleteFile ( string path ) : void
path string
리턴 void
예제 #1
0
        public void ConfigurationCacheIsClearedIfFileRemoved()
        {
            // Arrange
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(m => m.SolutionDirectory).Returns(@"bar\baz");
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile(@"bar\nuget.config", @"
            <settings>
            <repositoryPath>lib</repositoryPath>
            </settings>");
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(m => m.GetFileSystem(@"bar\baz")).Returns(fileSystem);
            var repositorySettings = new RepositorySettings(solutionManager.Object, fileSystemProvider.Object);

            // Act
            string p1 = repositorySettings.RepositoryPath;

            fileSystem.DeleteFile(@"bar\nuget.config");

            string p2 = repositorySettings.RepositoryPath;

            // Assert
            Assert.AreEqual(@"bar\lib", p1);
            Assert.AreEqual(@"bar\baz\packages", p2);
        }
예제 #2
0
        public void IsValidIsTrueWhenNupkgFileIsDeleted()
        {
            // Arrange
            var ms = GetPackageStream();

            var fileSystem = new MockFileSystem("x:\\");
            fileSystem.AddFile("pam.nupkg", ms);

            var expandedFileSystem = new MockFileSystem("y:\\");

            var ozp = new TestableOptimizedZipPackage(fileSystem, "pam.nupkg", expandedFileSystem);
            Assert.True(ozp.IsValid);

            // Act
            fileSystem.DeleteFile("pam.nupkg");

            // Assert
            Assert.False(ozp.IsValid);
        }
        public void FindPackageVerifiesPackageFileExistsOnFileSystemWhenCaching()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile(@"A.1.0.0.nupkg");

            var repository = new LocalPackageRepository(new DefaultPackagePathResolver(fileSystem, useSideBySidePaths: true), fileSystem, enableCaching: true);
            var searchedPaths = new List<string>();
            Func<string, IPackage> openPackage = p =>
            {
                searchedPaths.Add(p);
                return PackageUtility.CreatePackage("A", "1.0");
            };

            // Act - 1
            IPackage result = repository.FindPackage(openPackage, "A", new SemanticVersion("1.0"));

            // Assert - 1
            Assert.NotNull(result);
            Assert.Equal("A", result.Id);
            Assert.Equal(new SemanticVersion("1.0"), result.Version);

            // Act - 2
            fileSystem.DeleteFile("A.1.0.0.nupkg");
            result = repository.FindPackage(openPackage, "A", new SemanticVersion("1.0"));

            // Assert - 2
            Assert.Null(result);
        }