Пример #1
0
            public void WhenDeployingListOfFiles_ShouldCopyExistingFilesToRelativeSubFolder_Fact()
            {
                // Arrange
                var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target");

                var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict);

                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(false);
                fileSystem.Setup(f => f.DirectoryCreate(@"c:\temp\target"));
                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target\relative")).Returns(false);
                fileSystem.Setup(f => f.DirectoryCreate(@"c:\temp\target\relative"));

                fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file1.html")).Returns(true);
                fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file2.html")).Returns(true);
                fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file3.html")).Returns(false);
                fileSystem.Setup(f => f.FileCopy(@"c:\Temp\MySite\file1.html", @"c:\temp\target\relative\file1.html", true));
                fileSystem.Setup(f => f.FileCopy(@"c:\Temp\MySite\file2.html", @"c:\temp\target\relative\file2.html", true));

                // Act
                ApplicationExtensions.Deploy(app,
                                             new string[]
                {
                    @"c:\Temp\MySite\file1.html",
                    @"c:\Temp\MySite\file2.html",
                    @"c:\Temp\MySite\file3.html"
                },
                                             @"relative", fileSystem.Object);

                // Assert
                fileSystem.VerifyAll();
            }
            public void WhenVirtualDirectoryPathExist_ShouldJustCopy()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationDeployVirtualDirectoryPathExistShouldJustCopy();

                // Act, Assert
                ApplicationExtensions.Deploy(
                    mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                    @"c:\Temp\MySite",
                    mock.FileSystem.Object);
            }
Пример #3
0
            public void WhenSourceDoesNotExist_ShouldThrow_Fact()
            {
                // Arrange
                var app        = this._serverManager.Sites[0].Applications[0];
                var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict);

                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(false);

                // Act, Assert
                var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object));

                Xunit.Assert.Equal(@"Failed to deploy files to application, source directory does not exist: 'c:\Temp\MySite'.", exception.Message);
                fileSystem.VerifyAll();
            }
            public void WhenVirtualDirectoryPathExist_IfRelativePathProvided_ShouldCopyToRelative()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationDeployVirtualDirectoryPathExistIfRelativePathProvidedShouldCopyToRelative();

                // Act, Assert
                ApplicationExtensions.Deploy(
                    mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                    @"c:\Temp\MySite",
                    mock.FileSystem.Object,
                    @"..\otherfolder");
            }
            public void WhenVirtualDirectoryDoesNotExist_ShouldThrow()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationVirtualDirectoryDoesNotExist();
                // Act, Assert
                var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(
                                                              mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                                                              @"c:\Temp\MySite",
                                                              mock.FileSystem.Object));

                Assert.Equal(string.Format(@"Application '{0}' does not have a virtual directory.", mock.MockApplicationName), exception.Message);
            }
            public void WhenDeployingFileContent_ShouldCreateFile()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationDeployFileContentShouldCreateFile();

                // Act, Assert
                ApplicationExtensions.Deploy(
                    mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                    mock.MockRelativePath,
                    mock.MockSampleFileContent,
                    mock.FileSystem.Object);
            }
            public void WhenSourceDoesNotExist_ShouldThrow()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplicationDeploySourceDoesNotExist();

                // Act, Assert
                var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(
                                                              mock.ServerManager.Sites[0].Applications[0],
                                                              @"c:\Temp\MySite",
                                                              mock.FileSystem.Object));

                Assert.Equal(@"Failed to deploy files to application, source directory does not exist: 'c:\Temp\MySite'.", exception.Message);
            }
Пример #8
0
            public void WhenDeployingListOfFiles_IfListIsEmpty_ShouldThrow_Fact()
            {
                // Arrange
                var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target");

                var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict);

                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true);
                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(true);
                fileSystem.Setup(f => f.DirectoryCopy(@"c:\Temp\MySite", @"c:\temp\target"));

                // Act, Assert
                var exception = Assert.Throws <ArgumentNullException>(() => ApplicationExtensions.Deploy(app, (string[])null, "", fileSystem.Object));

                Xunit.Assert.True(exception.Message.Contains("filePaths"));
            }
            public void WhenDeployingListOfFiles_IfListIsEmpty_ShouldThrow()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationDeployListOfFilesIfListIsEmptyShouldThrow();

                // Act, Assert
                var exception = Assert.Throws <ArgumentNullException>(() => ApplicationExtensions.Deploy(
                                                                          mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                                                                          (string[])null,
                                                                          "",
                                                                          mock.FileSystem.Object));

                Assert.True(exception.Message.Contains("filePaths"));
            }
Пример #10
0
            public void WhenVirtualDirectoryPathExist_ShouldJustCopy_Fact()
            {
                // Arrange
                var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target");

                var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict);

                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true);
                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(true);
                fileSystem.Setup(f => f.DirectoryCopy(@"c:\Temp\MySite", @"c:\temp\target"));

                // Act
                ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object);

                // Assert
                fileSystem.VerifyAll();
            }
Пример #11
0
            public void WhenVirtualDirectoryDoesNotExist_ShouldThrow_Fact()
            {
                // Arrange
                var appName = Helper.Randomize("/test");
                var app     = this._serverManager.Sites[0].Applications.Add(appName, "");

                app.VirtualDirectories.Clear();

                var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict);

                fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true);

                // Act, Assert
                var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object));

                Xunit.Assert.Equal(string.Format(@"Application '{0}' does not have a virtual directory.", appName), exception.Message);
                fileSystem.VerifyAll();
            }
            public void WhenDeployingListOfFiles_ShouldCopyExistingFilesToRelativeSubFolder()
            {
                // Arrange
                var mock = new WebServerMockGenerator()
                           .MockApplication()
                           .MockApplicationDeployListOfFilesShouldCopyExistingFilesToRelativeSubFolder();

                // Act, Assert
                ApplicationExtensions.Deploy(
                    mock.ServerManager.Sites[0].Applications[mock.MockApplicationName],
                    new []
                {
                    @"c:\Temp\MySite\file1.html",
                    @"c:\Temp\MySite\file2.html",
                    @"c:\Temp\MySite\file3.html"
                },
                    @"relative",
                    mock.FileSystem.Object);
            }