NuGet.Test.Mocks.MockFileSystem.AddFile C# (CSharp) Method

AddFile() public method

public AddFile ( string path ) : void
path string
return void
        public virtual void AddFile(string path)
        {
            AddFile(path, new MemoryStream());
        }

Same methods

MockFileSystem::AddFile ( string path, Func getStream ) : void
MockFileSystem::AddFile ( string path, Stream stream ) : void
MockFileSystem::AddFile ( string path, Stream stream, bool overrideIfExists ) : void
MockFileSystem::AddFile ( string path, string content ) : void

Usage Example

        public void FindPackageFindTheRightPackage()
        {
            // Arrange
            var fileSystem = new MockFileSystem("c:\\");
            AddPackage(fileSystem, "A", "1.0");
            AddPackage(fileSystem, "B", "1.0-alpha");
            AddPackage(fileSystem, "C", "2.0.1-RC");
            AddPackage(fileSystem, "D", "3.0");

            // these are invalid packages (missing corresponding directory)
            fileSystem.AddFile("AA.2.0.nupkg");
            fileSystem.AddFile("BB.4.0.nupkg");
            fileSystem.CreateDirectory("BB.3.0");

            var pathResolver = new DefaultPackagePathResolver("c:\\");
            var repository = new UnzippedPackageRepository(pathResolver, fileSystem);

            // Act
            var packageA = repository.FindPackage("A", new SemanticVersion("1.0"));
            var packageB = repository.FindPackage("B", new SemanticVersion("1.0-alpha"));

            // Assert
            AssertPackage(packageA, "A", new SemanticVersion("1.0"));
            AssertPackage(packageB, "B", new SemanticVersion("1.0.0-alpha"));
        }
All Usage Examples Of NuGet.Test.Mocks.MockFileSystem::AddFile