当前位置: 首页>>代码示例>>C#>>正文


C# MockProjectSystem.ReadAllText方法代码示例

本文整理汇总了C#中NuGet.Test.Mocks.MockProjectSystem.ReadAllText方法的典型用法代码示例。如果您正苦于以下问题:C# MockProjectSystem.ReadAllText方法的具体用法?C# MockProjectSystem.ReadAllText怎么用?C# MockProjectSystem.ReadAllText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NuGet.Test.Mocks.MockProjectSystem的用法示例。


在下文中一共展示了MockProjectSystem.ReadAllText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRefreshFileUsesAbsolutePathIfRelativePathsCannotBeFormed

        public void CreateRefreshFileUsesAbsolutePathIfRelativePathsCannotBeFormed()
        {
            // Arrange
            var projectSystem = new MockProjectSystem(VersionUtility.DefaultTargetFramework, @"z:\test\site\");
            var assemblyPath = @"x:\test\packages\Foo.1.0\lib\net40\Bar.net40.dll";

            // Act
            projectSystem.CreateRefreshFile(assemblyPath);

            // Assert
            Assert.Equal(@"x:\test\packages\Foo.1.0\lib\net40\Bar.net40.dll", projectSystem.ReadAllText(@"bin\Bar.net40.dll.refresh"));
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:12,代码来源:ProjectSystemExtensionsTest.cs

示例2: CreateRefreshFileAddsRefreshFileUnderBinDirectory

        public void CreateRefreshFileAddsRefreshFileUnderBinDirectory()
        {
            // Arrange
            var projectSystem = new MockProjectSystem(VersionUtility.DefaultTargetFramework, @"x:\test\site\");
            var assemblyPath = @"x:\test\packages\Foo.1.0\lib\net40\Foo.dll";

            // Act
            projectSystem.CreateRefreshFile(assemblyPath);

            // Assert
            Assert.Equal(@"..\packages\Foo.1.0\lib\net40\Foo.dll", projectSystem.ReadAllText(@"bin\Foo.dll.refresh"));
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:12,代码来源:ProjectSystemExtensionsTest.cs

示例3: RemovingPackageWithModifiedContentFileWithinBeginMarkersRemoveFile

        public void RemovingPackageWithModifiedContentFileWithinBeginMarkersRemoveFile()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(
                sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            var packageA = PackageUtility.CreatePackage("A", "1.0", content: new[] { "a.file" });
            sourceRepository.AddPackage(packageA);

            projectManager.AddPackageReference("A");
            Assert.True(projectManager.LocalRepository.Exists(packageA));
            Assert.True(projectSystem.FileExists("a.file"));

            projectSystem.ReadAllText("a.file");

            // now modify 'a.file' to include ignore line markers
            projectSystem.AddFile("a.file", @"content\a.file
-----------------NUGET: BEGIN LICENSE TEXT
dsaflkdjsal;fkjdsal;kjf
sdafkljdsal;kjfl;dkasjfl;kdas
fdsalk;fj;lkdsajfl;kdsa");
            // Act 
            projectManager.RemovePackageReference("A");

            // Assert
            Assert.False(projectManager.LocalRepository.Exists(packageA));
            Assert.False(projectSystem.FileExists("a.file"));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:29,代码来源:ProjectManagerTest.cs

示例4: RemovingPackageWithModifiedContentFileWithinIgnoreMarkersSucceeds2

        public void RemovingPackageWithModifiedContentFileWithinIgnoreMarkersSucceeds2()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(
                sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            var packageA = PackageUtility.CreatePackage("A", "1.0", content: new[] { "a.file" });

            var contentFile = PackageUtility.CreateMockedPackageFile("content", "a.file", @"this is awesome.
*******NUGET: BEGIN LICENSE TEXT------------------
SDAFLKDSAJFL;KJDSAL;KFJL;DSAKJFL;KDSA
******NUGET: END LICENSE TEXT-------");

            var mockPackageA = Mock.Get<IPackage>(packageA);
            mockPackageA.Setup(p => p.GetFiles()).Returns(new[] { contentFile.Object });
            
            sourceRepository.AddPackage(packageA);

            projectManager.AddPackageReference("A");
            Assert.True(projectManager.LocalRepository.Exists(packageA));
            Assert.True(projectSystem.FileExists("a.file"));

            projectSystem.ReadAllText("a.file");

            // now modify 'a.file' to include ignore line markers
            projectSystem.AddFile("a.file", @"this is awesome.");

            // Act 
            projectManager.RemovePackageReference("A");

            // Assert
            Assert.False(projectManager.LocalRepository.Exists(packageA));
            Assert.False(projectSystem.FileExists("a.file"));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:35,代码来源:ProjectManagerTest.cs

示例5: AddPackageAskToResolveConflictForEveryFileWithDependency

        public void AddPackageAskToResolveConflictForEveryFileWithDependency()
        {
            // Arrange            
            var sourceRepository = new MockPackageRepository();
            var localRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            projectSystem.AddFile("one.txt", "this is one");
            projectSystem.AddFile("two.txt", "this is two");

            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);
            IPackage packageA = PackageUtility.CreatePackage(
                "A", "1.0", content: new[] { "one.txt" }, dependencies: new PackageDependency[] { new PackageDependency("B") });
            sourceRepository.AddPackage(packageA);

            IPackage packageB = PackageUtility.CreatePackage("B", "1.0", content: new[] { "two.txt" });
            sourceRepository.AddPackage(packageB);

            var logger = new Mock<ILogger>();
            logger.Setup(l => l.ResolveFileConflict(It.IsAny<string>())).Returns(FileConflictResolution.OverwriteAll);
            projectManager.Logger = projectSystem.Logger = logger.Object;

            // Act
            projectManager.AddPackageReference("A");

            // Assert
            Assert.True(localRepository.Exists("A"));
            Assert.Equal("content\\one.txt", projectSystem.ReadAllText("one.txt"));
            Assert.Equal("content\\two.txt", projectSystem.ReadAllText("two.txt"));

            logger.Verify(l => l.ResolveFileConflict(It.IsAny<string>()), Times.Exactly(2));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:31,代码来源:ProjectManagerTest.cs

示例6: UpdatePackageOverwriteAllFilesWhenFileConflictActionSetToOverwrite

        public void UpdatePackageOverwriteAllFilesWhenFileConflictActionSetToOverwrite()
        {
            // Arrange
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var constraintProvider = NullConstraintProvider.Instance;
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            var projectSystem = new MockProjectSystem();
            projectSystem.AddFile("one.txt", "this is one");
            projectSystem.AddFile("two.txt", "this is two");

            var packages = new List<IPackage>();
            var package_A10 = PackageUtility.CreatePackage("A", "1.0", content: new[] { "1.txt" });
            var package_A12 = PackageUtility.CreatePackage("A", "1.2", content: new[] { "one.txt", "two.txt" });
            localRepository.Add(package_A10);
            sourceRepository.Add(package_A12);

            var sharedRepository = new Mock<ISharedPackageRepository>(MockBehavior.Strict);
            sharedRepository.Setup(s => s.AddPackage(package_A12)).Callback<IPackage>(p => packages.Add(p));
            sharedRepository.Setup(s => s.GetPackages()).Returns(packages.AsQueryable());

            var repositoryFactory = new Mock<IPackageRepositoryFactory>();
            repositoryFactory.Setup(s => s.CreateRepository(It.IsAny<string>())).Returns(sourceRepository);

            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(s => s.LoadPackageSources()).Returns(new[] { new PackageSource("foo-source") });

            var console = new Mock<IConsole>();
            console.Setup(c => c.ResolveFileConflict(It.IsAny<string>())).Returns(FileConflictResolution.Ignore);

            var updateCommand = new UpdateCommand()
            {
                RepositoryFactory = repositoryFactory.Object,
                SourceProvider = packageSourceProvider.Object,
                Console = console.Object,
                FileConflictAction = FileConflictAction.Overwrite
            };

            // Act
            updateCommand.UpdatePackages(localRepository, fileSystem, sharedRepository.Object, sourceRepository, constraintProvider, pathResolver, projectSystem);

            // Assert
            Assert.True(localRepository.Exists("A", new SemanticVersion("1.2")));
            Assert.Equal("content\\one.txt", projectSystem.ReadAllText("one.txt"));
            Assert.Equal("content\\two.txt", projectSystem.ReadAllText("two.txt"));
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:47,代码来源:UpdateCommandTest.cs


注:本文中的NuGet.Test.Mocks.MockProjectSystem.ReadAllText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。