/// <summary> /// This method is called to enable Browser Link in an application. It /// registers a factory method that creates BrowserLinkMiddleware for /// each request. /// </summary> public static IApplicationBuilder UseBrowserLink(this IApplicationBuilder app) { if (!IsMicrosoftRuntime) { return(app); } try { string applicationBasePath; if (GetApplicationBasePath(app, out applicationBasePath)) { applicationBasePath = PathUtil.NormalizeDirectoryPath(applicationBasePath); HostConnectionUtil.SignalHostForStartup(applicationBasePath, blockUntilStarted: false); BrowserLinkMiddlewareFactory factory = new BrowserLinkMiddlewareFactory(applicationBasePath); return(app.Use(factory.CreateBrowserLinkMiddleware)); } else { // Browser Link doesn't work if we don't have an application path return(app); } } catch { // Something went wrong initializing the runtime. Browser Link won't work. return(app); } }
private void Test_ParseV1ConnectionData_ShouldFail() { // Act var result = HostConnectionUtil.ParseV1ConnectionData(FileName, SampleConnectionDataV1, out HostConnectionData connection); // Assert Assert.False(result, "ParseV1ConnectionData should fail."); Assert.Null(connection); }
private void Test_ParseV1ConnectionData( string fileName = FileNameBase, string expectedHttpConnectionString = ExpectedHttpConnectionString, string expectedHttpsConnectionString = ExpectedHttpsConnectionString, string expectedReadingSignalName = ExpectedReadySignalName, string expectedRequestSignalName = ExpectedRequestSignalName, string expectedInjectScriptVerb = ExpectedInjectScriptVerb, string expectedMappingDataVerb = ExpectedMappingDataVerb, string expectedServerDataVerb = null, IEnumerable <string> expectedProjectPaths = null) { // Arrange & act var result = HostConnectionUtil.ParseV1ConnectionData(fileName, SampleConnectionDataV1, out HostConnectionData connection); // Assert Assert.True(result, "ParseV1ConnectionData failed."); Assert.NotNull(connection); Assert.Equal(expectedHttpConnectionString, connection.ConnectionString); Assert.Equal(expectedHttpsConnectionString, connection.SslConnectionString); Assert.Equal(expectedRequestSignalName, connection.RequestSignalName); Assert.Equal(ExpectedReadySignalName, connection.ReadySignalName); Assert.Equal(expectedInjectScriptVerb, connection.InjectScriptVerb); Assert.Equal(expectedMappingDataVerb, connection.MappingDataVerb); Assert.Equal(expectedServerDataVerb, connection.ServerDataVerb); Assert.NotNull(connection.ProjectPaths); if (expectedProjectPaths == null) { expectedProjectPaths = new string[] { ExpectedProjectPath }; } IEnumerator <string> expectedIter = expectedProjectPaths.GetEnumerator(); IEnumerator <string> actualIter = connection.ProjectPaths.GetEnumerator(); while (expectedIter.MoveNext()) { Assert.True(actualIter.MoveNext(), "Expected to find <{0}> before the end of the {1} list"); Assert.Equal(expectedIter.Current, actualIter.Current); } Assert.False(actualIter.MoveNext(), "Too many items in the {0} list"); }
private void Test_ParseV2ConnectionData( string fileName = FileName, int expectedNumberOfConnections = 1, string expectedRequestSignalName = ExpectedRequestSignalName, string expectedReadySignalName = ExpectedReadySignalName, string expectedProjectPath = ExpectedProjectPath, string expectedHttpConnectionString = ExpectedHttpConnectionString, string expectedHttpsConnectionString = ExpectedHttpsConnectionString, string expectedInjectScriptVerb = ExpectedInjectScriptVerb, string expectedMappingDataVerb = ExpectedMappingDataVerb, string expectedServerDataVerb = ExpectedServerDataVerb) { // Act var result = HostConnectionUtil.ParseV2ConnectionData(fileName, SampleConnectionDataV2); // Assert Assert.NotNull(result); Assert.Equal(expectedNumberOfConnections, result.Count()); if (expectedNumberOfConnections > 0) { Assert.False(result.Any(x => x == null), "List should not contain null connections"); HostConnectionData connection = result.Where(x => x.ProjectPaths.First() == expectedProjectPath).SingleOrDefault(); Assert.NotNull(connection); Assert.Equal(expectedRequestSignalName, connection.RequestSignalName); Assert.Equal(expectedReadySignalName, connection.ReadySignalName); Assert.NotNull(connection.ProjectPaths); Assert.Single(connection.ProjectPaths); Assert.Equal(expectedProjectPath, connection.ProjectPaths.First()); Assert.Equal(expectedHttpConnectionString, connection.ConnectionString); Assert.Equal(expectedHttpsConnectionString, connection.SslConnectionString); Assert.Equal(expectedInjectScriptVerb, connection.InjectScriptVerb); Assert.Equal(expectedMappingDataVerb, connection.MappingDataVerb); Assert.Equal(expectedServerDataVerb, connection.ServerDataVerb); } }