Inheritance: PhysicalFileSystem
コード例 #1
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void BindToSourceControlAddsPaths()
        {
            var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // Use short paths for the names to test that full paths are used
            var paths = new string[]
            {
                Path.GetRandomFileName(),
                Path.GetRandomFileName(),
                Path.GetRandomFileName(),
            };

            var workspace = new Mock <ITfsWorkspace>();

            var target = new TfsFileSystem(workspace.Object, root);

            target.BindToSourceControl(paths);

            var expectedPaths = new string[]
            {
                Path.Combine(root, paths[0]),
                Path.Combine(root, paths[1]),
                Path.Combine(root, paths[2]),
            };

            // Validate the full paths were used when binding
            workspace.Verify(w => w.PendAdd(It.Is <IEnumerable <string> >(v => !v.Except(expectedPaths).Any())), Times.Once());
        }
コード例 #2
0
        public void BindToSourceControlThrowsArgumentNullExceptionIfPathIsNull()
        {
            var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var target = new TfsFileSystem(Mock.Of<ITfsWorkspace>(), root);

            var exception = Assert.Throws<ArgumentNullException>(() => target.BindToSourceControl(null));
            Assert.Equal("paths", exception.ParamName, StringComparer.Ordinal);
        }
コード例 #3
0
        public void AddFileThrowsArgumentNullExceptionIfWriteToStreamIsNull()
        {
            var workspace = Mock.Of<ITfsWorkspace>();
            var root = Path.GetRandomFileName();
            var target = new TfsFileSystem(workspace, root);

            ExceptionAssert.ThrowsArgNull(() => target.AddFile(Path.GetRandomFileName(), writeToStream: null), "writeToStream");
        }
コード例 #4
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void AddFileThrowsArgumentNullExceptionIfStreamIsNull()
        {
            var workspace = Mock.Of <ITfsWorkspace>();
            var root      = Path.GetRandomFileName();
            var target    = new TfsFileSystem(workspace, root);

            ExceptionAssert.ThrowsArgNull(() => target.AddFile(Path.GetRandomFileName(), null), "stream");
        }
コード例 #5
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void BindToSourceControlThrowsArgumentNullExceptionIfPathIsNull()
        {
            var root   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var target = new TfsFileSystem(Mock.Of <ITfsWorkspace>(), root);

            var exception = Assert.Throws <ArgumentNullException>(() => target.BindToSourceControl(null));

            Assert.Equal("paths", exception.ParamName, StringComparer.Ordinal);
        }
コード例 #6
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void BeginProcessingAllowsNullBatchForUninstall()
        {
            // Arrange
            var root   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var target = new TfsFileSystem(Mock.Of <ITfsWorkspace>(), root);

            // Act and Assert
            ExceptionAssert.ThrowsArgNull(() => target.BeginProcessing(null, PackageAction.Uninstall), "batch");
        }
コード例 #7
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void BeginProcessingThrowsArgumentNullExceptionIfPathIsNull()
        {
            var root   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var target = new TfsFileSystem(Mock.Of <ITfsWorkspace>(), root);

            var exception = Assert.Throws <ArgumentNullException>(() => target.BeginProcessing(null, PackageAction.Install));

            Assert.Equal("batch", exception.ParamName, StringComparer.Ordinal);
        }
コード例 #8
0
        public void ConstructorForWorkspaceInterfaceInitializesInstance()
        {
            var workspace = Mock.Of<ITfsWorkspace>();
            var root = Path.GetRandomFileName();

            var target = new TfsFileSystem(workspace, root);

            Assert.Equal(root, target.Root, StringComparer.Ordinal);
            Assert.Same(workspace, target.Workspace);
        }
コード例 #9
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void ConstructorForWorkspaceInterfaceInitializesInstance()
        {
            var workspace = Mock.Of <ITfsWorkspace>();
            var root      = Path.GetRandomFileName();

            var target = new TfsFileSystem(workspace, root);

            Assert.Equal(root, target.Root, StringComparer.Ordinal);
            Assert.Same(workspace, target.Workspace);
        }
コード例 #10
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void IsSourceControlBoundReturnsTrueIfInWorkspace()
        {
            var root = Path.GetTempPath();
            var path = Path.GetRandomFileName();

            var workspace = new Mock <ITfsWorkspace>();

            workspace.Setup(w => w.ItemExists(It.IsAny <string>()))
            .Returns(true);

            var target = new TfsFileSystem(workspace.Object, root);

            bool result = target.IsSourceControlBound(path);

            workspace.Verify(w => w.ItemExists(Path.Combine(root, path)), Times.Once());

            Assert.True(result, "File was incorrectly determined to not be source control bound.");
        }
コード例 #11
0
ファイル: TfsFileSystemTest.cs プロジェクト: hu19891110/NuGet
        public void DeleteDirectoryIfPathDoesNotExist()
        {
            var root     = Path.GetTempPath();
            var path     = Path.GetRandomFileName();
            var fullPath = Path.Combine(root, path);

            var workspace = new Mock <ITfsWorkspace>();

            workspace.Setup(w => w.ItemExists(It.IsAny <string>()))
            .Returns(false);

            var target = new TfsFileSystem(workspace.Object, root);

            target.DeleteDirectory(path);

            workspace.Verify(w => w.GetPendingChanges(fullPath), Times.Once());
            workspace.Verify(w => w.PendDelete(fullPath, RecursionType.None), Times.Once());
            workspace.Verify(w => w.Undo(It.IsAny <IEnumerable <ITfsPendingChange> >()), Times.Once());
        }
コード例 #12
0
        public void BindToSourceControlAddsPaths()
        {
            var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // Use short paths for the names to test that full paths are used
            var paths = new string[]
            {
                Path.GetRandomFileName(),
                Path.GetRandomFileName(),
                Path.GetRandomFileName(),
            };

            var workspace = new Mock<ITfsWorkspace>();

            var target = new TfsFileSystem(workspace.Object, root);

            target.BindToSourceControl(paths);

            var expectedPaths = new string[]
            {
                Path.Combine(root, paths[0]),
                Path.Combine(root, paths[1]),
                Path.Combine(root, paths[2]),
            };

            // Validate the full paths were used when binding
            workspace.Verify(w => w.PendAdd(It.Is<IEnumerable<string>>(v => !v.Except(expectedPaths).Any() )), Times.Once());
        }
コード例 #13
0
 public void BeginProcessingAllowsNullBatchForUninstall()
 {
     // Arrange
     var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
     var target = new TfsFileSystem(Mock.Of<ITfsWorkspace>(), root);
     
     // Act and Assert
     ExceptionAssert.ThrowsArgNull(() => target.BeginProcessing(null, PackageAction.Uninstall), "batch");
 }
コード例 #14
0
        public void BeginProcessingThrowsArgumentNullExceptionIfPathIsNull()
        {
            var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var target = new TfsFileSystem(Mock.Of<ITfsWorkspace>(), root);

            var exception = Assert.Throws<ArgumentNullException>(() => target.BeginProcessing(null, PackageAction.Install));
            Assert.Equal("batch", exception.ParamName, StringComparer.Ordinal);
        }
コード例 #15
0
        public void DeleteDirectoryIfPathDoesNotExist()
        {
            var root = Path.GetTempPath();
            var path = Path.GetRandomFileName();
            var fullPath = Path.Combine(root, path);

            var workspace = new Mock<ITfsWorkspace>();

            workspace.Setup(w => w.ItemExists(It.IsAny<string>()))
                .Returns(false);

            var target = new TfsFileSystem(workspace.Object, root);

            target.DeleteDirectory(path);

            workspace.Verify(w => w.GetPendingChanges(fullPath), Times.Once());
            workspace.Verify(w => w.PendDelete(fullPath, RecursionType.None), Times.Once());
            workspace.Verify(w => w.Undo(It.IsAny<IEnumerable<ITfsPendingChange>>()), Times.Once());
        }
コード例 #16
0
        public void IsSourceControlBoundReturnsTrueIfInWorkspace()
        {
            var root = Path.GetTempPath();
            var path = Path.GetRandomFileName();

            var workspace = new Mock<ITfsWorkspace>();

            workspace.Setup(w => w.ItemExists(It.IsAny<string>()))
                .Returns(true);

            var target = new TfsFileSystem(workspace.Object, root);

            bool result = target.IsSourceControlBound(path);

            workspace.Verify(w => w.ItemExists(Path.Combine(root, path)), Times.Once());

            Assert.True(result, "File was incorrectly determined to not be source control bound.");
        }