예제 #1
0
            public void WhenIisExpressAndRemoteFalse_IfLocateIisExpressAndArchitectureDefault1_ShouldUseProgramFiles()
            {
                // Arrange
                const string webSiteName = "MyWebSite";

                _mock.MockToolsHelperGetUniqueTempPath(webSiteName)
                .MockIisExpressRootPathInCurrentDir()
                .MockWebServerIisExpressCtor_GetNextAvailablePort()
                .MockWebServerIisExpressCtor_LocateIisExpress_ProgramFiles()
                .MockWebServerIisExpressCtor_CreateApplicationHostConfigFromTemplate_Found_UniqueAppPath(_mock.MockIisExpressPath)
                .MockIisExpressConfig_ApplicationConfigFound(_mock.MockApplicationHostConfigPath)
                .MockIisExpressConfig_RealDocumentInitialized(_mock.MockApplicationHostConfigPath)
                .MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath)
                .MockWebServerIisExpressStart(_mock.MockIisExpressPath)
                .MockWebServerCreate_RemoteFalse();
                TestEasyHelpers.Tools = _mock.ToolsHelper.Object;

                // Act
                var server = new WebServerIisExpress(new WebServerSettings {
                    WebAppName = webSiteName
                }, _dependencies);

                // Assert
                Assert.Equal("IISExpress", server.Type);
                Assert.Equal("localhost", server.HostName);
                Assert.Equal(_mock.MockUniqueTempPath, server.RootPhysicalPath);
                Assert.Equal(_mock.MockApplicationHostConfigPath, server.Configs["applicationhost.config"]);
                Assert.Equal("11.0", server.Version.ToString(2));

                _mock.MockWebServerIisExpressStop(_mock.MockIisExpressPath);
                server.Stop();
            }
예제 #2
0
            public void WhenIisExpressAndRemoteFalse_IfLocateIisExpressAndArchitectureDefault_ShouldUseProgramFiles()
            {
                // Arrange
                _mock.MockIisExpressRootPathInCurrentDir()
                .MockWebServerIisExpressCtor_GetNextAvailablePort()
                .MockWebServerIisExpressCtor_LocateIisExpress_ProgramFiles()
                .MockWebServerIisExpressCtor_CreateApplicationHostConfigFromTemplate_Found(_mock.MockIisExpressPath)
                .MockIisExpressConfig_ApplicationConfigFound(_mock.MockApplicationHostConfigPath)
                .MockIisExpressConfig_RealDocumentInitialized(_mock.MockApplicationHostConfigPath)
                .MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath)
                .MockWebServerIisExpressStart(_mock.MockIisExpressPath)
                .MockWebServerCreate_RemoteFalse();

                // Act
                var server = new WebServerIisExpress(new WebServerSettings(), _dependencies);

                // Assert
                Assert.Equal("IISExpress", server.Type);
                Assert.Equal("localhost", server.HostName);
                Assert.Equal(Path.GetDirectoryName(_mock.MockCurrentExecutableDir), server.RootPhysicalPath);
                Assert.Equal(_mock.MockApplicationHostConfigPath, server.Configs["applicationhost.config"]);
                Assert.Equal("11.0", server.Version.ToString(2));

                _mock.MockWebServerIisExpressStop(_mock.MockIisExpressPath);
                server.Stop();

                _mock.MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath);
                var appInfo = server.CreateWebApplication("MyNewApp");

                Assert.Equal("MyNewApp", appInfo.Name);
                Assert.Equal(@"c:\currentdir\MyNewApp", appInfo.PhysicalPath);
                Assert.Equal(string.Format("http://{0}:1000/MyNewApp", Environment.MachineName), appInfo.RemoteVirtualPath);
                Assert.Equal("http://*****:*****@"c:\currentdir\MyNewApp", newAppInfo.PhysicalPath);
                Assert.Equal(string.Format("http://{0}:1000/MyNewApp", Environment.MachineName), newAppInfo.RemoteVirtualPath);
                Assert.Equal("http://localhost:1000/MyNewApp", newAppInfo.VirtualPath);

                _mock.MockWebServerIisExpress_DeleteApp(newAppInfo.PhysicalPath);
                server.DeleteWebApplication("MyNewApp");
                newAppInfo = server.GetWebApplicationInfo("MyNewApp");
                Assert.Null(newAppInfo);
            }
            public void WhenIisExpressAndRemoteFalse_IfLocateIisExpressAndArchitectureDefault_ShouldUseProgramFiles()
            {
                // Arrange  
                _mock.MockIisExpressRootPathInCurrentDir()
                    .MockWebServerIisExpressCtor_GetNextAvailablePort()
                    .MockWebServerIisExpressCtor_LocateIisExpress_ProgramFiles()
                    .MockWebServerIisExpressCtor_CreateApplicationHostConfigFromTemplate_Found(_mock.MockIisExpressPath)
                    .MockIisExpressConfig_ApplicationConfigFound(_mock.MockApplicationHostConfigPath)
                    .MockIisExpressConfig_RealDocumentInitialized(_mock.MockApplicationHostConfigPath)
                    .MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath)
                    .MockWebServerIisExpressStart(_mock.MockIisExpressPath)
                    .MockWebServerCreate_RemoteFalse();

                // Act
                var server = new WebServerIisExpress(new WebServerSettings(), _dependencies);

                // Assert 
                Assert.Equal("IISExpress", server.Type);
                Assert.Equal("localhost", server.HostName);
                Assert.Equal(Path.GetDirectoryName(_mock.MockCurrentExecutableDir), server.RootPhysicalPath);
                Assert.Equal(_mock.MockApplicationHostConfigPath, server.Configs["applicationhost.config"]);
                Assert.Equal("11.0", server.Version.ToString(2));

                _mock.MockWebServerIisExpressStop(_mock.MockIisExpressPath);
                server.Stop();

                _mock.MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath);
                var appInfo = server.CreateWebApplication("MyNewApp");

                Assert.Equal("MyNewApp", appInfo.Name);
                Assert.Equal(@"c:\currentdir\MyNewApp", appInfo.PhysicalPath);
                Assert.Equal(string.Format("http://{0}:1000/MyNewApp", Environment.MachineName), appInfo.RemoteVirtualPath);
                Assert.Equal("http://*****:*****@"c:\currentdir\MyNewApp", newAppInfo.PhysicalPath);
                Assert.Equal(string.Format("http://{0}:1000/MyNewApp", Environment.MachineName), newAppInfo.RemoteVirtualPath);
                Assert.Equal("http://localhost:1000/MyNewApp", newAppInfo.VirtualPath);

                _mock.MockWebServerIisExpress_DeleteApp(newAppInfo.PhysicalPath);
                server.DeleteWebApplication("MyNewApp");
                newAppInfo = server.GetWebApplicationInfo("MyNewApp");
                Assert.Null(newAppInfo);
            }
            public void WhenIisExpressAndRemoteFalse_IfLocateIisExpressAndArchitectureDefault1_ShouldUseProgramFiles()
            {
                // Arrange  
                const string webSiteName = "MyWebSite";
                _mock.MockToolsHelperGetUniqueTempPath(webSiteName)
                    .MockIisExpressRootPathInCurrentDir()
                    .MockWebServerIisExpressCtor_GetNextAvailablePort()
                    .MockWebServerIisExpressCtor_LocateIisExpress_ProgramFiles()
                    .MockWebServerIisExpressCtor_CreateApplicationHostConfigFromTemplate_Found_UniqueAppPath(_mock.MockIisExpressPath)
                    .MockIisExpressConfig_ApplicationConfigFound(_mock.MockApplicationHostConfigPath)
                    .MockIisExpressConfig_RealDocumentInitialized(_mock.MockApplicationHostConfigPath)
                    .MockIisExpressConfig_StoreSchema(_mock.MockApplicationHostConfigPath)
                    .MockWebServerIisExpressStart(_mock.MockIisExpressPath)
                    .MockWebServerCreate_RemoteFalse();
                TestEasyHelpers.Tools = _mock.ToolsHelper.Object;

                // Act
                var server = new WebServerIisExpress(new WebServerSettings { WebAppName = webSiteName }, _dependencies);

                // Assert 
                Assert.Equal("IISExpress", server.Type);
                Assert.Equal("localhost", server.HostName);
                Assert.Equal(_mock.MockUniqueTempPath, server.RootPhysicalPath);
                Assert.Equal(_mock.MockApplicationHostConfigPath, server.Configs["applicationhost.config"]);
                Assert.Equal("11.0", server.Version.ToString(2));

                _mock.MockWebServerIisExpressStop(_mock.MockIisExpressPath);
                server.Stop();
            }