diff --git a/src/MusicStore.Spa/wwwroot/ng-apps/MusicStore.Store/Home/Home.html b/src/MusicStore.Spa/wwwroot/ng-apps/MusicStore.Store/Home/Home.html index ca35168092..3bfb802705 100644 --- a/src/MusicStore.Spa/wwwroot/ng-apps/MusicStore.Store/Home/Home.html +++ b/src/MusicStore.Spa/wwwroot/ng-apps/MusicStore.Store/Home/Home.html @@ -1,6 +1,6 @@ 

MVC Music Store

- +
diff --git a/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs b/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs index 9ce074271d..c4086025a9 100644 --- a/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs +++ b/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs @@ -5,11 +5,8 @@ using System.Threading.Tasks; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Rendering; -using Microsoft.AspNet.SignalR; -using Microsoft.AspNet.SignalR.Infrastructure; using Microsoft.Data.Entity; using Microsoft.Framework.Caching.Memory; -using MusicStore.Hubs; using MusicStore.Models; using MusicStore.ViewModels; @@ -19,29 +16,12 @@ namespace MusicStore.Areas.Admin.Controllers [Microsoft.AspNet.Authorization.Authorize("ManageStore")] public class StoreManagerController : Controller { - private IConnectionManager _connectionManager; - private IHubContext _announcementHub; - [FromServices] public MusicStoreContext DbContext { get; set; } [FromServices] public IMemoryCache Cache { get; set; } - [FromServices] - public IConnectionManager ConnectionManager - { - get - { - return _connectionManager; - } - set - { - _connectionManager = value; - _announcementHub = _connectionManager.GetHubContext(); - } - } - // // GET: /StoreManager/ public async Task Index() @@ -113,7 +93,6 @@ namespace MusicStore.Areas.Admin.Controllers Url = Url.Action("Details", "Store", new { id = album.AlbumId }) }; - _announcementHub.Clients.All.announcement(albumData); Cache.Remove("latestAlbum"); return RedirectToAction("Index"); } diff --git a/src/MusicStore/Components/AnnouncementComponent.cs b/src/MusicStore/Components/AnnouncementComponent.cs deleted file mode 100644 index 4ff81bac19..0000000000 --- a/src/MusicStore/Components/AnnouncementComponent.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; -using Microsoft.Data.Entity; -using Microsoft.Framework.Caching.Memory; -using MusicStore.Models; - -namespace MusicStore.Components -{ - [ViewComponent(Name = "Announcement")] - public class AnnouncementComponent : ViewComponent - { - public AnnouncementComponent(MusicStoreContext dbContext, IMemoryCache cache, ISystemClock clock) - { - DbContext = dbContext; - Cache = cache; - Clock = clock; - } - - private MusicStoreContext DbContext { get; } - - private IMemoryCache Cache { get; } - - private ISystemClock Clock { get; } - - public async Task InvokeAsync() - { - var cacheKey = "latestAlbum"; - Album latestAlbum; - if(!Cache.TryGetValue(cacheKey, out latestAlbum)) - { - latestAlbum = await GetLatestAlbum(); - - if (latestAlbum != null) - { - Cache.Set( - cacheKey, - latestAlbum, - new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(10))); - } - } - - return View(latestAlbum); - } - - private async Task GetLatestAlbum() - { - var latestAlbum = await DbContext.Albums - .OrderByDescending(a => a.Created) - .Where(a => (a.Created - Clock.UtcNow).TotalDays <= 2) - .FirstOrDefaultAsync(); - - return latestAlbum; - } - } -} \ No newline at end of file diff --git a/src/MusicStore/Hubs/AnnouncementHub.cs b/src/MusicStore/Hubs/AnnouncementHub.cs deleted file mode 100644 index c4933e6e4b..0000000000 --- a/src/MusicStore/Hubs/AnnouncementHub.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNet.SignalR; -using Microsoft.AspNet.SignalR.Hubs; - -namespace MusicStore.Hubs -{ - [HubName("Announcement")] - public class AnnouncementHub : Hub - { - - } -} \ No newline at end of file diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index 53ecfa3075..3172d89def 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -102,9 +102,6 @@ namespace MusicStore // Add MVC services to the services container services.AddMvc(); - //Add all SignalR related services to IoC. - services.AddSignalR(); - //Add InMemoryCache services.AddSingleton(); @@ -178,9 +175,6 @@ namespace MusicStore // Configure Session. app.UseSession(); - //Configure SignalR - app.UseSignalR(); - // Add static files to the request pipeline app.UseStaticFiles(); diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index b1ad93c2b4..8c800acbe9 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -18,11 +18,11 @@ using MusicStore.Models; namespace MusicStore { /// - /// To make runtime to load an environment based startup class, specify the environment by the following ways: + /// To make runtime to load an environment based startup class, specify the environment by the following ways: /// 1. Drop a Microsoft.AspNet.Hosting.ini file in the wwwroot folder /// 2. Add a setting in the ini file named 'ASPNET_ENV' with value of the format 'Startup[EnvironmentName]'. For example: To load a Startup class named - /// 'StartupNtlmAuthentication' the value of the env should be 'NtlmAuthentication' (eg. ASPNET_ENV=NtlmAuthentication). Runtime adds a 'Startup' prefix to this and loads 'StartupNtlmAuthentication'. - /// If no environment name is specified the default startup class loaded is 'Startup'. + /// 'StartupNtlmAuthentication' the value of the env should be 'NtlmAuthentication' (eg. ASPNET_ENV=NtlmAuthentication). Runtime adds a 'Startup' prefix to this and loads 'StartupNtlmAuthentication'. + /// If no environment name is specified the default startup class loaded is 'Startup'. /// Alternative ways to specify environment are: /// 1. Set the environment variable named SET ASPNET_ENV=NtlmAuthentication /// 2. For selfhost based servers pass in a command line variable named --env with this value. Eg: @@ -34,7 +34,7 @@ namespace MusicStore { public StartupNtlmAuthentication(IApplicationEnvironment env) { - //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, + //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") @@ -65,9 +65,6 @@ namespace MusicStore // Add MVC services to the services container services.AddMvc(); - //Add all SignalR related services to IoC. - services.AddSignalR(); - //Add InMemoryCache services.AddSingleton(); @@ -95,8 +92,8 @@ namespace MusicStore // Note: Not recommended for production. app.UseErrorPage(); - // Set up NTLM authentication for WebListener like below. - // For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or modify the applicationHost.config to enable NTLM. + // Set up NTLM authentication for WebListener like below. + // For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or modify the applicationHost.config to enable NTLM. if ((app.Server as ServerInformation) != null) { var serverInformation = (ServerInformation)app.Server; @@ -126,9 +123,6 @@ namespace MusicStore // Configure Session. app.UseSession(); - //Configure SignalR - app.UseSignalR(); - // Add static files to the request pipeline app.UseStaticFiles(); diff --git a/src/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/StartupOpenIdConnect.cs index 7fbd3ced95..2d6679f633 100644 --- a/src/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/StartupOpenIdConnect.cs @@ -16,11 +16,11 @@ using MusicStore.Models; namespace MusicStore { /// - /// To make runtime to load an environment based startup class, specify the environment by the following ways: + /// To make runtime to load an environment based startup class, specify the environment by the following ways: /// 1. Drop a Microsoft.AspNet.Hosting.ini file in the wwwroot folder /// 2. Add a setting in the ini file named 'ASPNET_ENV' with value of the format 'Startup[EnvironmentName]'. For example: To load a Startup class named - /// 'StartupOpenIdConnect' the value of the env should be 'OpenIdConnect' (eg. ASPNET_ENV=OpenIdConnect). Runtime adds a 'Startup' prefix to this and loads 'StartupOpenIdConnect'. - /// If no environment name is specified the default startup class loaded is 'Startup'. + /// 'StartupOpenIdConnect' the value of the env should be 'OpenIdConnect' (eg. ASPNET_ENV=OpenIdConnect). Runtime adds a 'Startup' prefix to this and loads 'StartupOpenIdConnect'. + /// If no environment name is specified the default startup class loaded is 'Startup'. /// Alternative ways to specify environment are: /// 1. Set the environment variable named SET ASPNET_ENV=OpenIdConnect /// 2. For selfhost based servers pass in a command line variable named --env with this value. Eg: @@ -34,7 +34,7 @@ namespace MusicStore public StartupOpenIdConnect(IApplicationEnvironment env, IRuntimeEnvironment runtimeEnvironment) { - //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, + //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") @@ -90,9 +90,6 @@ namespace MusicStore // Add MVC services to the services container services.AddMvc(); - //Add all SignalR related services to IoC. - services.AddSignalR(); - //Add InMemoryCache services.AddSingleton(); @@ -130,9 +127,6 @@ namespace MusicStore // Configure Session. app.UseSession(); - //Configure SignalR - app.UseSignalR(); - // Add static files to the request pipeline app.UseStaticFiles(); diff --git a/src/MusicStore/Views/Shared/_Layout.cshtml b/src/MusicStore/Views/Shared/_Layout.cshtml index 601877f659..52ffb26d0c 100644 --- a/src/MusicStore/Views/Shared/_Layout.cshtml +++ b/src/MusicStore/Views/Shared/_Layout.cshtml @@ -23,24 +23,6 @@ - - diff --git a/src/MusicStore/project.json b/src/MusicStore/project.json index 9a2d47d3d2..37f2e662f0 100644 --- a/src/MusicStore/project.json +++ b/src/MusicStore/project.json @@ -13,7 +13,6 @@ "dependencies": { "EntityFramework.InMemory": "7.0.0-*", "EntityFramework.SqlServer": "7.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Antiforgery": "1.0.0-*", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*", @@ -27,9 +26,9 @@ "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.Session": "1.0.0-*", - "Microsoft.AspNet.SignalR.Server": "3.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*", "Microsoft.AspNet.Tooling.Razor": "1.0.0-*", "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*", diff --git a/test/E2ETests/Implementation/Validator.cs b/test/E2ETests/Implementation/Validator.cs index e3ea01d99a..13b0da92ee 100644 --- a/test/E2ETests/Implementation/Validator.cs +++ b/test/E2ETests/Implementation/Validator.cs @@ -6,7 +6,6 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Server.Testing; -using Microsoft.AspNet.SignalR.Client; using Microsoft.Framework.Logging; using Xunit; @@ -346,20 +345,6 @@ namespace E2ETests public async Task CreateAlbum() { var albumName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12); -#if DNX451 - string dataFromHub = null; - var OnReceivedEvent = new AutoResetEvent(false); - var hubConnection = new HubConnection(_deploymentResult.ApplicationBaseUri + "SignalR"); - hubConnection.Received += (data) => - { - _logger.LogVerbose("Data received by SignalR client: {receivedData}", data); - dataFromHub = data; - OnReceivedEvent.Set(); - }; - - IHubProxy proxy = hubConnection.CreateHubProxy("Announcement"); - await hubConnection.Start(); -#endif _logger.LogInformation("Trying to create an album with name '{album}'", albumName); var response = await _httpClient.GetAsync("Admin/StoreManager/create"); await ThrowIfResponseStatusNotOk(response); @@ -379,12 +364,6 @@ namespace E2ETests responseContent = await response.Content.ReadAsStringAsync(); Assert.Equal(_deploymentResult.ApplicationBaseUri + "Admin/StoreManager", response.RequestMessage.RequestUri.AbsoluteUri); Assert.Contains(albumName, responseContent); -#if DNX451 - _logger.LogInformation("Waiting for the SignalR client to receive album created announcement"); - OnReceivedEvent.WaitOne(TimeSpan.FromSeconds(10)); - dataFromHub = dataFromHub ?? "No relevant data received from Hub"; - Assert.Contains(albumName, dataFromHub); -#endif _logger.LogInformation("Successfully created an album with name '{album}' in the store", albumName); return albumName; } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs index 99ced17861..fb250cb421 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs @@ -25,7 +25,7 @@ namespace MusicStore public StartupOpenIdConnectTesting(IApplicationEnvironment env, IRuntimeEnvironment runtimeEnvironment) { - //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, + //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") @@ -98,9 +98,6 @@ namespace MusicStore // Add MVC services to the services container services.AddMvc(); - //Add all SignalR related services to IoC. - services.AddSignalR(); - //Add InMemoryCache services.AddSingleton(); @@ -138,9 +135,6 @@ namespace MusicStore // Configure Session. app.UseSession(); - //Configure SignalR - app.UseSignalR(); - // Add static files to the request pipeline app.UseStaticFiles(); diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index 027a2cbf35..5966d653f0 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -154,9 +154,6 @@ namespace MusicStore // Add MVC services to the services container services.AddMvc(); - //Add all SignalR related services to IoC. - services.AddSignalR(); - //Add InMemoryCache services.AddSingleton(); @@ -194,9 +191,6 @@ namespace MusicStore // Configure Session. app.UseSession(); - //Configure SignalR - app.UseSignalR(); - // Add static files to the request pipeline app.UseStaticFiles(); diff --git a/test/E2ETests/project.json b/test/E2ETests/project.json index cd9952b69e..d869579acd 100644 --- a/test/E2ETests/project.json +++ b/test/E2ETests/project.json @@ -8,7 +8,6 @@ "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.Testing": "1.0.0-*", - "Microsoft.AspNet.SignalR.Client": "2.1.1", "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-*", "Microsoft.Framework.Logging.Console": "1.0.0-*", diff --git a/test/MusicStore.Test/AnnouncementComponentTest.cs b/test/MusicStore.Test/AnnouncementComponentTest.cs deleted file mode 100644 index 2a8556a723..0000000000 --- a/test/MusicStore.Test/AnnouncementComponentTest.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; -using Microsoft.Data.Entity; -using Microsoft.Framework.Caching.Memory; -using Microsoft.Framework.DependencyInjection; -using MusicStore.Models; -using Xunit; - -namespace MusicStore.Components -{ - public class AnnouncementComponentTest - { - private readonly IServiceProvider _serviceProvider; - - public AnnouncementComponentTest() - { - var services = new ServiceCollection(); - - services.AddEntityFramework() - .AddInMemoryDatabase() - .AddDbContext(options => - options.UseInMemoryDatabase()); - - _serviceProvider = services.BuildServiceProvider(); - } - - [Fact] - public async Task AnnouncementComponent_Returns_LatestAlbum() - { - // Arrange - var today = new DateTime(year: 2002, month: 10, day: 30); - - var dbContext = _serviceProvider.GetRequiredService(); - var cache = _serviceProvider.GetRequiredService(); - var clock = new TestSystemClock() { UtcNow = today }; - - var announcementComponent = new AnnouncementComponent(dbContext, cache, clock); - - PopulateData(dbContext, latestAlbumDate: today); - - // Action - var result = await announcementComponent.InvokeAsync(); - - // Assert - Assert.NotNull(result); - var viewResult = Assert.IsType(result); - Assert.Null(viewResult.ViewName); - var albumResult = Assert.IsType(viewResult.ViewData.Model); - Assert.Equal(today, albumResult.Created.Date); - } - - private static void PopulateData(DbContext context, DateTime latestAlbumDate) - { - var albums = TestAlbumDataProvider.GetAlbums(latestAlbumDate); - - foreach (var album in albums) - { - context.Add(album); - } - - context.SaveChanges(); - } - - private class TestAlbumDataProvider - { - public static Album[] GetAlbums(DateTime latestAlbumDate) - { - var generes = Enumerable.Range(1, 10).Select(n => - new Genre() - { - GenreId = n, - Name = "Genre Name " + n, - }).ToArray(); - - var artists = Enumerable.Range(1, 10).Select(n => - new Artist() - { - ArtistId = n + 1, - Name = "Artist Name " + n, - }).ToArray(); - - var albums = Enumerable.Range(1, 10).Select(n => - new Album() - { - Artist = artists[n - 1], - ArtistId = n, - Genre = generes[n - 1], - GenreId = n, - Created = latestAlbumDate.AddDays(1 - n), - }).ToArray(); - - return albums; - } - } - - private class TestSystemClock : ISystemClock - { - public DateTime UtcNow { get; set; } - } - } -}