當前位置: 首頁>>代碼示例>>C#>>正文


C# MockFileSystem.DeleteFile方法代碼示例

本文整理匯總了C#中NuGet.Test.Mocks.MockFileSystem.DeleteFile方法的典型用法代碼示例。如果您正苦於以下問題:C# MockFileSystem.DeleteFile方法的具體用法?C# MockFileSystem.DeleteFile怎麽用?C# MockFileSystem.DeleteFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NuGet.Test.Mocks.MockFileSystem的用法示例。


在下文中一共展示了MockFileSystem.DeleteFile方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ConfigurationCacheIsClearedIfFileRemoved

        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);
        }
開發者ID:larsw,項目名稱:nuget,代碼行數:25,代碼來源:RepositorySettingsTest.cs

示例2: IsValidIsTrueWhenNupkgFileIsDeleted

        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);
        }
開發者ID:Newtopian,項目名稱:nuget,代碼行數:19,代碼來源:OptimizedZipPackageTest.cs

示例3: FindPackageVerifiesPackageFileExistsOnFileSystemWhenCaching

        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);
        }
開發者ID:sistoimenov,項目名稱:NuGet2,代碼行數:29,代碼來源:LocalPackageRepositoryTest.cs


注:本文中的NuGet.Test.Mocks.MockFileSystem.DeleteFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。