diff --git a/.gitignore b/.gitignore index d5a3d96..e98be26 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ nuget.exe *.ipch bower_components/ node_modules/ +.vs/ +project.lock.json diff --git a/ApplicationInsights.AspNet.sln b/ApplicationInsights.AspNet.sln index 9b4de36..8fc28fd 100644 --- a/ApplicationInsights.AspNet.sln +++ b/ApplicationInsights.AspNet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22609.0 +VisualStudioVersion = 14.0.22809.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2E6DDE9E-8C75-4F9C-8906-08EBDD6E73EF}" EndProject @@ -12,15 +12,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Readme.md = Readme.md EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationInsights.AspNet", "src\ApplicationInsights.AspNet\ApplicationInsights.AspNet.kproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNet", "src\Microsoft.ApplicationInsights.AspNet\Microsoft.ApplicationInsights.AspNet.xproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8B5230E5-8138-44D6-839F-DF9248F195EE}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationInsights.AspNet.UnitTests", "test\ApplicationInsights.AspNet.Tests\ApplicationInsights.AspNet.UnitTests.kproj", "{2766D8AF-C20B-4F3A-8260-6C2D39B7A8A0}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNet.Tests", "test\Microsoft.ApplicationInsights.AspNet.Tests\Microsoft.ApplicationInsights.AspNet.Tests.xproj", "{2766D8AF-C20B-4F3A-8260-6C2D39B7A8A0}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebAppIntegration", "test\SampleWebAppIntegration\SampleWebAppIntegration.kproj", "{330152EC-1092-41F0-9F96-C3438E07FCC2}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebAppIntegration", "test\SampleWebAppIntegration\SampleWebAppIntegration.xproj", "{330152EC-1092-41F0-9F96-C3438E07FCC2}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FunctionalTestUtils", "test\FunctionalTestUtils\FunctionalTestUtils.kproj", "{B7217A00-66FA-49A8-8EF3-39C07E1F7E33}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FunctionalTestUtils", "test\FunctionalTestUtils\FunctionalTestUtils.xproj", "{B7217A00-66FA-49A8-8EF3-39C07E1F7E33}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Readme.md b/Readme.md index 797a3e5..80326d5 100644 --- a/Readme.md +++ b/Readme.md @@ -82,9 +82,8 @@ Developing ---------- 1. Repository (private now): https://github.com/microsoft/AppInsights-aspnetv5 2. Asp.Net information: https://github.com/aspnet/home -3. VS 2015 installation: - - *(recommended by [Anastasia](https://github.com/abaranch))*: http://blogs.msdn.com/b/visualstudioalm/archive/2014/06/04/visual-studio-14-ctp-now-available-in-the-virtual-machine-azure-gallery.aspx - - You can just install it on your machine: https://www.visualstudio.com/en-us/news/vs2015-vs.aspx +3. Install VS 2015 RC. + Running and writing tests ------------------------- @@ -106,9 +105,7 @@ Add dependencies to project.json: ``` "FunctionalTestUtils": "1.0.0-*", -"xunit": "2.1.0.0-beta1-build2945", -"xunit.runner.aspnet": "2.1.0.0-beta1-build60", -"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051" +"xunit.runner.aspnet": "2.0.0-aspnet-beta5-*", ``` and test command: @@ -122,3 +119,10 @@ Add this initialization logic to Startup.cs: ``` services.AddFunctionalTestTelemetryChannel(); ``` + +*Running Tests* +Open a developer command prompt, navigate to project folder and run: +``` +dnx . test +``` + diff --git a/global.json b/global.json index d6a8b85..8ea9041 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sources": [ "src", "test" ], "sdk": { - "version": "1.0.0-beta3" + "version": "1.0.0-beta4" } } diff --git a/src/ApplicationInsights.AspNet/project.json b/src/ApplicationInsights.AspNet/project.json deleted file mode 100644 index f0e6a0f..0000000 --- a/src/ApplicationInsights.AspNet/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "0.30.0.1-beta", - "dependencies": { - "Microsoft.AspNet.Hosting": "1.0.0-beta3", - "Microsoft.Framework.Logging": "1.0.0-beta3", - "Microsoft.AspNet.Http.Extensions": "1.0.0-beta3", - "Microsoft.AspNet.RequestContainer": "1.0.0-beta3", - "Microsoft.AspNet.Mvc.Core": "6.0.0-beta3", - "System.Net.NameResolution": "4.0.0-beta-*" - }, - - "frameworks": { - "aspnet50": { - "dependencies": { - "Microsoft.ApplicationInsights": "0.13.4-build00460" - } - }, - "aspnetcore50": { - "dependencies": { - "System.Runtime": "4.0.20-*", - "Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta" - } - } - } -} diff --git a/src/ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs b/src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs similarity index 99% rename from src/ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs rename to src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs index 426e999..c8569fb 100644 --- a/src/ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExceptionMiddleware.cs @@ -33,4 +33,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs b/src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs similarity index 99% rename from src/ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs rename to src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs index 7770ac8..d814640 100644 --- a/src/ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsExtensions.cs @@ -17,7 +17,7 @@ public static IApplicationBuilder UseApplicationInsightsRequestTelemetry(this IApplicationBuilder app) { // TODO: Register if customer did not register - app.UseRequestServices(); + //app.UseRequestServices(); app.UseMiddleware(); return app; diff --git a/src/ApplicationInsights.AspNet/ApplicationInsightsRequestMiddleware.cs b/src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsRequestMiddleware.cs similarity index 100% rename from src/ApplicationInsights.AspNet/ApplicationInsightsRequestMiddleware.cs rename to src/Microsoft.ApplicationInsights.AspNet/ApplicationInsightsRequestMiddleware.cs diff --git a/src/ApplicationInsights.AspNet/ContextInitializers/DomainNameRoleInstanceContextInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/ContextInitializers/DomainNameRoleInstanceContextInitializer.cs similarity index 100% rename from src/ApplicationInsights.AspNet/ContextInitializers/DomainNameRoleInstanceContextInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/ContextInitializers/DomainNameRoleInstanceContextInitializer.cs diff --git a/src/ApplicationInsights.AspNet/ApplicationInsights.AspNet.kproj b/src/Microsoft.ApplicationInsights.AspNet/Microsoft.ApplicationInsights.AspNet.xproj similarity index 77% rename from src/ApplicationInsights.AspNet/ApplicationInsights.AspNet.kproj rename to src/Microsoft.ApplicationInsights.AspNet/Microsoft.ApplicationInsights.AspNet.xproj index 0408ecb..26887fa 100644 --- a/src/ApplicationInsights.AspNet/ApplicationInsights.AspNet.kproj +++ b/src/Microsoft.ApplicationInsights.AspNet/Microsoft.ApplicationInsights.AspNet.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 95ec3635-22e4-4c3a-a066-f5823a0648da Microsoft.ApplicationInsights.AspNet @@ -20,8 +19,6 @@ True - - True - - + + \ No newline at end of file diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs similarity index 99% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs index 498229c..3ede8ee 100644 --- a/src/ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs @@ -4,7 +4,6 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Http; - using Microsoft.AspNet.Http.Interfaces; using System.Collections.Generic; using System.Net.Sockets; using System.Net; diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/OperationIdTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/OperationIdTelemetryInitializer.cs similarity index 100% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/OperationIdTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/OperationIdTelemetryInitializer.cs diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/OperationNameTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/OperationNameTelemetryInitializer.cs similarity index 100% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/OperationNameTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/OperationNameTelemetryInitializer.cs diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs similarity index 96% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs index 5f3a0f8..1fdba9c 100644 --- a/src/ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/TelemetryInitializerBase.cs @@ -27,7 +27,7 @@ { try { - var context = this.httpContextAccessor.Value; + var context = this.httpContextAccessor.HttpContext; if (context == null) { diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs similarity index 96% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs index 4aba9d0..e7bcc08 100644 --- a/src/ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/UserAgentTelemetryInitializer.cs @@ -4,7 +4,6 @@ using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; - using Microsoft.AspNet.Http.Core; using Microsoft.Net.Http.Headers; using System; diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/WebSessionTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/WebSessionTelemetryInitializer.cs similarity index 100% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/WebSessionTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/WebSessionTelemetryInitializer.cs diff --git a/src/ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs similarity index 96% rename from src/ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs index 97bc5a9..a63ec6f 100644 --- a/src/ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs +++ b/src/Microsoft.ApplicationInsights.AspNet/TelemetryInitializers/WebUserTelemetryInitializer.cs @@ -50,7 +50,7 @@ if (userCookieParts.Length >= 2) { // todo: add tracing - DateTimeOffset acquisitionDate; + DateTimeOffset acquisitionDate = DateTimeOffset.MinValue; if (!string.IsNullOrEmpty(userCookieParts[1]) && DateTimeOffset.TryParse(userCookieParts[1], CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out acquisitionDate)) { diff --git a/src/Microsoft.ApplicationInsights.AspNet/project.json b/src/Microsoft.ApplicationInsights.AspNet/project.json new file mode 100644 index 0000000..5402540 --- /dev/null +++ b/src/Microsoft.ApplicationInsights.AspNet/project.json @@ -0,0 +1,47 @@ +{ + "description": "Application Insights for ASP.NET 5 web applications. See http://go.microsoft.com/fwlink/?LinkID=510752 for more information.", + "authors": [ "Microsoft" ], + "version": "1.0.0-*", + "projectUrl": "https://github.com/Microsoft/AppInsights-aspnetv5", + "tags": [ "Analytics", "ApplicationInsights", "Telemetry", "AppInsights" ], + /* TODO: Include and verify additional properties after upgrading to VS2015 RC and beta 5. + * For details, see: + * https://github.com/aspnet/dnx/issues/1302 + * https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Framework.PackageManager/Building/BuildManager.cs#L237 + + "title": "Application Insights for ASP.NET 5 Web Applications", + "copyright": "Copyright © Microsoft. All Rights Reserved.", + "iconUrl": "http://appanacdn.blob.core.windows.net/cdn/icons/aic.png", + "licenseUrl": "http://go.microsoft.com/fwlink/?LinkID=510709", + "requireLicenseAcceptance": true, + + * Do we need these? + "summary": "Application Insights for ASP.NET 5 Web Applications", + "owners": ["AppInsightsSdk"], + */ + "dependencies": { + "Microsoft.AspNet.Hosting": "1.0.0-beta5-*", + "Microsoft.Framework.Logging": "1.0.0-beta5-*", + "Microsoft.AspNet.Http": "1.0.0-beta5-*", + "Microsoft.AspNet.Http.Extensions": "1.0.0-beta5-*", + "Microsoft.AspNet.Mvc.Core": "6.0.0-beta5-*", + "System.Net.NameResolution": "4.0.0-beta-*" + }, + + "frameworks": { + "dnx451": { + "dependencies": { + "Microsoft.ApplicationInsights": "0.13.4-build00460" + } + }, + "dnxcore50": { + "dependencies": { + "System.Collections": "4.0.10-beta-22807", + "System.Linq": "4.0.0-beta-22807", + "System.Threading": "4.0.10-beta-22807", + "Microsoft.CSharp": "4.0.0-beta-22807", + "Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta" + } + } + } +} \ No newline at end of file diff --git a/test/ApplicationInsights.AspNet.Tests/project.json b/test/ApplicationInsights.AspNet.Tests/project.json deleted file mode 100644 index 09d7cca..0000000 --- a/test/ApplicationInsights.AspNet.Tests/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "dependencies": { - "ApplicationInsights.AspNet": "0.30.0.1-beta", - "xunit": "2.1.0.0-beta1-build2945", - "xunit.runner.aspnet": "2.1.0.0-beta1-build60", - "xunit.runner.visualstudio": "2.1.0.0-beta1-build1051", - "Microsoft.AspNet.FeatureModel": "1.0.0-beta3", - "Microsoft.AspNet.Http.Extensions": "1.0.0-beta3", - "Microsoft.AspNet.Hosting": "1.0.0-beta3", - "Microsoft.Framework.Logging": "1.0.0-beta3", - "Microsoft.AspNet.Http.Extensions": "1.0.0-beta3", - "Microsoft.AspNet.RequestContainer": "1.0.0-beta3", - "Microsoft.AspNet.Mvc.Core": "6.0.0-beta3", - "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3" - }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } - } -} \ No newline at end of file diff --git a/test/FunctionalTestUtils/FunctionalTestUtils.kproj b/test/FunctionalTestUtils/FunctionalTestUtils.xproj similarity index 80% rename from test/FunctionalTestUtils/FunctionalTestUtils.kproj rename to test/FunctionalTestUtils/FunctionalTestUtils.xproj index dd30c5a..76c3627 100644 --- a/test/FunctionalTestUtils/FunctionalTestUtils.kproj +++ b/test/FunctionalTestUtils/FunctionalTestUtils.xproj @@ -4,17 +4,15 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - b7217a00-66fa-49a8-8ef3-39c07e1f7e33 FunctionalTestUtils ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 - + + \ No newline at end of file diff --git a/test/FunctionalTestUtils/InProcessServer.cs b/test/FunctionalTestUtils/InProcessServer.cs index 0365867..37bc728 100644 --- a/test/FunctionalTestUtils/InProcessServer.cs +++ b/test/FunctionalTestUtils/InProcessServer.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; - using Microsoft.Framework.DependencyInjection.Fallback; + using Microsoft.Framework.Runtime; using System; public class InProcessServer : IDisposable @@ -31,25 +31,11 @@ var config = new Configuration(); config.Add(customConfig); - var serviceCollection = HostingServices.Create(null); - var services = serviceCollection.BuildServiceProvider(); - - var context = new HostingContext() - { - Services = services, - Configuration = config, - ServerName = "Microsoft.AspNet.Server.WebListener", - ApplicationName = assemblyName, - EnvironmentName = "Production" - }; - - var hostingEngine = services.GetService(); - if (hostingEngine == null) - { - throw new Exception("TODO: IHostingEngine service not available exception"); - } - - this.hostingEngine = hostingEngine.Start(context); + var engine = WebHost.CreateEngine(null, config) + .UseEnvironment("Production") + .UseServer("Microsoft.AspNet.Server.WebListener") + .UseStartup(assemblyName); + this.hostingEngine = engine.Start(); } public void Dispose() diff --git a/test/FunctionalTestUtils/project.json b/test/FunctionalTestUtils/project.json index 193c1b7..e3f8c39 100644 --- a/test/FunctionalTestUtils/project.json +++ b/test/FunctionalTestUtils/project.json @@ -1,10 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Diagnostics": "1.0.0-beta3", - "Microsoft.AspNet.Hosting": "1.0.0-beta3", - "Microsoft.AspNet.Mvc": "6.0.0-beta3", - "Microsoft.AspNet.Server.WebListener": "1.0.0-beta3", + "Microsoft.AspNet.Diagnostics": "1.0.0-beta5-*", + "Microsoft.AspNet.Hosting": "1.0.0-beta5-*", + "Microsoft.AspNet.Mvc": "6.0.0-beta5-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5-*", "xunit": "2.1.0.0-beta1-build2945", "xunit.runner.aspnet": "2.1.0.0-beta1-build60", "xunit.runner.visualstudio": "2.1.0.0-beta1-build1051", @@ -12,14 +12,17 @@ }, "frameworks": { - "aspnet50": { + "dnx451": { "dependencies": { "Microsoft.ApplicationInsights": "0.13.4-build00460" } }, - "aspnetcore50": { + "dnxcore50": { "dependencies": { - "System.Runtime": "4.0.20-beta-22523", + "System.Collections": "4.0.10-beta-22807", + "System.Linq": "4.0.0-beta-22807", + "System.Threading": "4.0.10-beta-22807", + "Microsoft.CSharp": "4.0.0-beta-22807", "Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta" } } diff --git a/test/ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs similarity index 76% rename from test/ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs index e22ed05..0d3d471 100644 --- a/test/ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/ApplicationInsightsExtensionsTests.cs @@ -12,11 +12,18 @@ using Microsoft.AspNet.Hosting; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; - using Microsoft.Framework.DependencyInjection.Fallback; using Xunit; public static class ApplicationInsightsExtensionsTests { + public static ServiceCollection GetServiceCollectionWithContextAccessor() + { + var services = new ServiceCollection(); + IHttpContextAccessor contextAccessor = new HttpContextAccessor(); + services.AddInstance(contextAccessor); + return services; + } + public static class SetApplicationInsightsTelemetryDeveloperMode { [Fact] @@ -24,7 +31,7 @@ { var telemetryChannel = new FakeTelemetryChannel(); var telemetryConfiguration = new TelemetryConfiguration { TelemetryChannel = telemetryChannel }; - var services = new ServiceCollection(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddInstance(telemetryConfiguration); var app = new ApplicationBuilder(services.BuildServiceProvider()); @@ -37,29 +44,29 @@ public static class AddApplicationInsightsTelemetry { [Theory] - [InlineData(typeof(IContextInitializer), typeof(DomainNameRoleInstanceContextInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(ClientIpHeaderTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(OperationNameTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(OperationIdTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(UserAgentTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(WebSessionTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(ITelemetryInitializer), typeof(WebUserTelemetryInitializer), LifecycleKind.Singleton)] - [InlineData(typeof(TelemetryConfiguration), null, LifecycleKind.Singleton)] - [InlineData(typeof(TelemetryClient), typeof(TelemetryClient), LifecycleKind.Scoped)] - public static void RegistersExpectedServices(Type serviceType, Type implementationType, LifecycleKind lifecycle) + [InlineData(typeof(IContextInitializer), typeof(DomainNameRoleInstanceContextInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(ClientIpHeaderTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(OperationNameTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(OperationIdTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(UserAgentTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(WebSessionTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(ITelemetryInitializer), typeof(WebUserTelemetryInitializer), ServiceLifetime.Singleton)] + [InlineData(typeof(TelemetryConfiguration), null, ServiceLifetime.Singleton)] + [InlineData(typeof(TelemetryClient), typeof(TelemetryClient), ServiceLifetime.Scoped)] + public static void RegistersExpectedServices(Type serviceType, Type implementationType, ServiceLifetime lifecycle) { - var services = new ServiceCollection(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddApplicationInsightsTelemetry(new Configuration()); - IServiceDescriptor service = services.Single(s => s.ServiceType == serviceType && s.ImplementationType == implementationType); - Assert.Equal(lifecycle, service.Lifecycle); + ServiceDescriptor service = services.Single(s => s.ServiceType == serviceType && s.ImplementationType == implementationType); + Assert.Equal(lifecycle, service.Lifetime); } [Fact] public static void DoesNotThrowWithoutInstrumentationKey() { - var services = new ServiceCollection(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); //Empty configuration that doesn't have instrumentation key IConfiguration config = new Configuration(); @@ -70,7 +77,7 @@ [Fact] public static void RegistersTelemetryConfigurationFactoryMethodThatCreatesDefaultInstance() { - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddApplicationInsightsTelemetry(new Configuration()); @@ -82,8 +89,8 @@ [Fact] public static void RegistersTelemetryConfigurationFactoryMethodThatReadsInstrumentationKeyFromConfiguration() { - IServiceCollection services = HostingServices.Create(); - var config = new Configuration().AddJsonFile("content\\config.json"); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); + var config = new Configuration(".").AddJsonFile("content\\config.json"); services.AddApplicationInsightsTelemetry(config); @@ -96,7 +103,7 @@ public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithContextInitializersFromContainer() { var contextInitializer = new FakeContextInitializer(); - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddInstance(contextInitializer); services.AddApplicationInsightsTelemetry(new Configuration()); @@ -110,7 +117,7 @@ public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithTelemetryInitializersFromContainer() { var telemetryInitializer = new FakeTelemetryInitializer(); - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddInstance(telemetryInitializer); services.AddApplicationInsightsTelemetry(new Configuration()); @@ -124,7 +131,7 @@ public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithTelemetryChannelFromContainer() { var telemetryChannel = new FakeTelemetryChannel(); - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddInstance(telemetryChannel); services.AddApplicationInsightsTelemetry(new Configuration()); @@ -137,7 +144,7 @@ [Fact] public static void DoesNotOverrideDefaultTelemetryChannelIfTelemetryChannelServiceIsNotRegistered() { - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddApplicationInsightsTelemetry(new Configuration()); @@ -149,7 +156,7 @@ [Fact] public static void RegistersTelemetryClientToGetTelemetryConfigurationFromContainerAndNotGlobalInstance() { - IServiceCollection services = HostingServices.Create(); + var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddApplicationInsightsTelemetry(new Configuration()); diff --git a/test/ApplicationInsights.AspNet.Tests/ContextInitializers/DomainNameRoleInstanceContextInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/ContextInitializers/DomainNameRoleInstanceContextInitializerTests.cs similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/ContextInitializers/DomainNameRoleInstanceContextInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/ContextInitializers/DomainNameRoleInstanceContextInitializerTests.cs diff --git a/test/ApplicationInsights.AspNet.Tests/FakeContextInitializer.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/FakeContextInitializer.cs similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/FakeContextInitializer.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/FakeContextInitializer.cs diff --git a/test/ApplicationInsights.AspNet.Tests/FakeTelemetryChannel.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/FakeTelemetryChannel.cs similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/FakeTelemetryChannel.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/FakeTelemetryChannel.cs diff --git a/test/ApplicationInsights.AspNet.Tests/FakeTelemetryInitializer.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/FakeTelemetryInitializer.cs similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/FakeTelemetryInitializer.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/FakeTelemetryInitializer.cs diff --git a/test/ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs similarity index 85% rename from test/ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs index 7993be6..9f4b63d 100644 --- a/test/ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/Helpers/HtmlHelperMock.cs @@ -6,6 +6,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; + using Microsoft.AspNet.Mvc.ModelBinding.Validation; + using Microsoft.Framework.Internal; + using Microsoft.Framework.WebEncoders; internal class HtmlHelperMock : IHtmlHelper { @@ -22,6 +25,14 @@ } } + public IHtmlEncoder HtmlEncoder + { + get + { + throw new NotImplementedException(); + } + } + public string IdAttributeDotReplacement { get @@ -35,6 +46,14 @@ } } + public IJavaScriptStringEncoder JavaScriptStringEncoder + { + get + { + throw new NotImplementedException(); + } + } + public IModelMetadataProvider MetadataProvider { get @@ -43,6 +62,22 @@ } } + public ITempDataDictionary TempData + { + get + { + throw new NotImplementedException(); + } + } + + public IUrlEncoder UrlEncoder + { + get + { + throw new NotImplementedException(); + } + } + public dynamic ViewBag { get @@ -142,7 +177,17 @@ throw new NotImplementedException(); } - public IEnumerable GetClientValidationRules(ModelMetadata metadata, string name) + public IEnumerable GetClientValidationRules(ModelExplorer modelExplorer, string expression) + { + throw new NotImplementedException(); + } + + public IEnumerable GetEnumSelectList(Type enumType) + { + throw new NotImplementedException(); + } + + public IEnumerable GetEnumSelectList() where TEnum : struct { throw new NotImplementedException(); } diff --git a/test/ApplicationInsights.AspNet.Tests/Helpers/TestServiceProvider.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/Helpers/TestServiceProvider.cs similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/Helpers/TestServiceProvider.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/Helpers/TestServiceProvider.cs diff --git a/test/ApplicationInsights.AspNet.Tests/ApplicationInsights.AspNet.UnitTests.kproj b/test/Microsoft.ApplicationInsights.AspNet.Tests/Microsoft.ApplicationInsights.AspNet.Tests.xproj similarity index 85% rename from test/ApplicationInsights.AspNet.Tests/ApplicationInsights.AspNet.UnitTests.kproj rename to test/Microsoft.ApplicationInsights.AspNet.Tests/Microsoft.ApplicationInsights.AspNet.Tests.xproj index 5e99163..d084334 100644 --- a/test/ApplicationInsights.AspNet.Tests/ApplicationInsights.AspNet.UnitTests.kproj +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/Microsoft.ApplicationInsights.AspNet.Tests.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 2766d8af-c20b-4f3a-8260-6c2d39b7a8a0 @@ -24,5 +23,6 @@ True - + + \ No newline at end of file diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs similarity index 69% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs index f5cc880..81b022a 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs @@ -4,7 +4,7 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; + using Microsoft.AspNet.Http; using System; using System.Collections.Generic; using Xunit; @@ -20,7 +20,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new ClientIpHeaderTelemetryInitializer(ac); @@ -30,7 +30,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new ClientIpHeaderTelemetryInitializer(ac); @@ -40,10 +40,10 @@ [Fact] public void InitializeSetsIPFromStandardHeader() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var requestTelemetry = new RequestTelemetry(); - ac.Value.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" }); - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + ac.HttpContext.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" }); + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new ClientIpHeaderTelemetryInitializer(ac); @@ -55,10 +55,10 @@ [Fact] public void InitializeSetsIPFromCustomHeader() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var requestTelemetry = new RequestTelemetry(); - ac.Value.Request.Headers.Add("HEADER", new string[] { "127.0.0.3;127.0.0.4" }); - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + ac.HttpContext.Request.Headers.Add("HEADER", new string[] { "127.0.0.3;127.0.0.4" }); + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new ClientIpHeaderTelemetryInitializer(ac); initializer.HeaderNames.Add("HEADER"); initializer.HeaderValueSeparators = ",;"; @@ -73,9 +73,9 @@ { var requestTelemetry = new RequestTelemetry(); requestTelemetry.Context.Location.Ip = "127.0.0.4"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" }); - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" }); + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new ClientIpHeaderTelemetryInitializer(ac); initializer.Initialize(requestTelemetry); diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs similarity index 76% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs index f711495..9754678 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationIdTelemetryInitializerTest.cs @@ -4,7 +4,7 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; + using Microsoft.AspNet.Http; using System; using System.Collections.Generic; using Xunit; @@ -20,7 +20,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new OperationIdTelemetryInitializer(ac); @@ -30,7 +30,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new OperationIdTelemetryInitializer(ac); @@ -42,8 +42,8 @@ { var telemetry = new EventTelemetry(); telemetry.Context.Operation.Id = "123"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); var initializer = new OperationIdTelemetryInitializer(ac); initializer.Initialize(telemetry); @@ -56,8 +56,8 @@ { var telemetry = new EventTelemetry(); var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new OperationIdTelemetryInitializer(ac); initializer.Initialize(telemetry); diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs similarity index 76% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs index 67d5b22..31088f0 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs @@ -4,7 +4,7 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; + using Microsoft.AspNet.Http; using System; using System.Collections.Generic; using Xunit; @@ -20,7 +20,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new OperationNameTelemetryInitializer(ac); @@ -30,7 +30,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new OperationNameTelemetryInitializer(ac); @@ -42,8 +42,8 @@ { var telemetry = new EventTelemetry(); telemetry.Context.Operation.Name = "Name"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); var initializer = new OperationNameTelemetryInitializer(ac); initializer.Initialize(telemetry); @@ -58,8 +58,8 @@ var request = new DefaultHttpContext().Request; request.Method = "GET"; request.Path = new Microsoft.AspNet.Http.PathString("/Test"); - var ac = new HttpContextAccessor() { Value = request.HttpContext }; - ac.Value.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); + var ac = new HttpContextAccessor() { HttpContext = request.HttpContext }; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); var initializer = new OperationNameTelemetryInitializer(ac); initializer.Initialize(telemetry); @@ -74,8 +74,8 @@ var request = new DefaultHttpContext().Request; request.Method = "GET"; request.Path = new Microsoft.AspNet.Http.PathString("/Test"); - var ac = new HttpContextAccessor() { Value = request.HttpContext }; - ac.Value.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); + var ac = new HttpContextAccessor() { HttpContext = request.HttpContext }; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { new RequestTelemetry() }); var initializer = new OperationNameTelemetryInitializer(ac); initializer.Initialize(telemetry); diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs similarity index 75% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs index fce67e8..9db66a5 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/UserAgentTelemetryInitializerTests.cs @@ -4,7 +4,7 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; + using Microsoft.AspNet.Http; using System; using System.Collections.Generic; using Xunit; @@ -20,7 +20,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new UserAgentTelemetryInitializer(ac); @@ -30,7 +30,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new UserAgentTelemetryInitializer(ac); @@ -41,9 +41,9 @@ public void InitializeSetsUserAgentFromHeader() { var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers.Add("User-Agent", new[] { "test" }); - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers.Add("User-Agent", new[] { "test" }); + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new UserAgentTelemetryInitializer(ac); initializer.Initialize(requestTelemetry); @@ -56,8 +56,8 @@ { var requestTelemetry = new RequestTelemetry(); requestTelemetry.Context.User.UserAgent = "Inline"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers.Add("User-Agent", new[] { "test" }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers.Add("User-Agent", new[] { "test" }); var serviceProvider = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new UserAgentTelemetryInitializer(ac); diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs similarity index 73% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs index b9ba3a6..fca6c23 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs @@ -6,8 +6,8 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; using Xunit; + using Microsoft.AspNet.Http; public class WebSessionTelemetryInitializerTests { @@ -20,7 +20,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new WebSessionTelemetryInitializer(ac); @@ -30,7 +30,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new WebSessionTelemetryInitializer(ac); @@ -41,9 +41,9 @@ public void InitializeSetsSessionFromCookie() { var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z"; - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z"; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebSessionTelemetryInitializer(ac); initializer.Initialize(requestTelemetry); @@ -56,8 +56,8 @@ { var requestTelemetry = new RequestTelemetry(); requestTelemetry.Context.Session.Id = "Inline"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z"; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z"; var serviceProvider = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebSessionTelemetryInitializer(ac); diff --git a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs similarity index 73% rename from test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs rename to test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs index e980eeb..62ad94b 100644 --- a/test/ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs @@ -4,11 +4,11 @@ using Microsoft.ApplicationInsights.AspNet.Tests.Helpers; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.AspNet.Hosting; - using Microsoft.AspNet.Http.Core; + using Microsoft.AspNet.Http; using System; using System.Collections.Generic; - using Xunit; using System.Globalization; + using Xunit; public class WebUserTelemetryInitializerTests { @@ -21,7 +21,7 @@ [Fact] public void InitializeDoesNotThrowIfHttpContextIsUnavailable() { - var ac = new HttpContextAccessor() { Value = null }; + var ac = new HttpContextAccessor() { HttpContext = null }; var initializer = new WebUserTelemetryInitializer(ac); @@ -31,7 +31,7 @@ [Fact] public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable() { - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; var initializer = new WebUserTelemetryInitializer(ac); @@ -42,9 +42,9 @@ public void InitializeSetsUserFromCookie() { var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z"; - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z"; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebUserTelemetryInitializer(ac); initializer.Initialize(requestTelemetry); @@ -58,8 +58,8 @@ { var requestTelemetry = new RequestTelemetry(); requestTelemetry.Context.User.Id = "Inline"; - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z"; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z"; var serviceProvider = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebUserTelemetryInitializer(ac); @@ -72,8 +72,8 @@ public void InitializeDoesNotThrowOnMalformedUserCookie() { var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_user=test"; + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test"; var serviceProvider = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebUserTelemetryInitializer(ac); @@ -86,9 +86,9 @@ public void InitializeDoesNotNotThrowOnMalformedAcquisitionDate() { var requestTelemetry = new RequestTelemetry(); - var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() }; - ac.Value.Request.Headers["Cookie"] = "ai_user=test|malformeddate"; - ac.Value.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); + var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() }; + ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|malformeddate"; + ac.HttpContext.RequestServices = new TestServiceProvider(new List() { requestTelemetry }); var initializer = new WebUserTelemetryInitializer(ac); initializer.Initialize(requestTelemetry); diff --git a/test/ApplicationInsights.AspNet.Tests/content/config.json b/test/Microsoft.ApplicationInsights.AspNet.Tests/content/config.json similarity index 100% rename from test/ApplicationInsights.AspNet.Tests/content/config.json rename to test/Microsoft.ApplicationInsights.AspNet.Tests/content/config.json diff --git a/test/Microsoft.ApplicationInsights.AspNet.Tests/project.json b/test/Microsoft.ApplicationInsights.AspNet.Tests/project.json new file mode 100644 index 0000000..670c0a8 --- /dev/null +++ b/test/Microsoft.ApplicationInsights.AspNet.Tests/project.json @@ -0,0 +1,21 @@ +{ + "dependencies": { + "Microsoft.ApplicationInsights.AspNet": "0.30.0.1-beta", + "xunit.runner.aspnet": "2.0.0-aspnet-beta5-*", + "Microsoft.AspNet.FeatureModel": "1.0.0-beta5-*", + "Microsoft.AspNet.Http": "1.0.0-beta5-*", + "Microsoft.AspNet.Http.Extensions": "1.0.0-beta5-*", + "Microsoft.AspNet.Hosting": "1.0.0-beta5-*", + "Microsoft.Framework.Logging": "1.0.0-beta5-*", + "Microsoft.AspNet.Mvc.Core": "6.0.0-beta5-*", + "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { + } + } +} diff --git a/test/SampleWebAppIntegration/Controllers/AccountController.cs b/test/SampleWebAppIntegration/Controllers/AccountController.cs index 78d8628..78f9f26 100644 --- a/test/SampleWebAppIntegration/Controllers/AccountController.cs +++ b/test/SampleWebAppIntegration/Controllers/AccountController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Principal; using System.Threading.Tasks; +using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Mvc; using SampleWebAppIntegration.Models; @@ -148,7 +149,7 @@ namespace SampleWebAppIntegration.Controllers private async Task GetCurrentUserAsync() { - return await UserManager.FindByIdAsync(Context.User.Identity.GetUserId()); + return await UserManager.FindByNameAsync(Context.User.Identity.Name); } public enum ManageMessageId diff --git a/test/SampleWebAppIntegration/Migrations/000000000000000_CreateIdentitySchema.cs b/test/SampleWebAppIntegration/Migrations/000000000000000_CreateIdentitySchema.cs deleted file mode 100644 index e75888c..0000000 --- a/test/SampleWebAppIntegration/Migrations/000000000000000_CreateIdentitySchema.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using Microsoft.Data.Entity; -using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Relational.Migrations; -using Microsoft.Data.Entity.Relational.Migrations.Builders; -using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; - -namespace SampleWebAppIntegration.Migrations -{ - public partial class CreateIdentitySchema : Migration - { - public override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable("AspNetRoles", - c => new - { - Id = c.String(), - Name = c.String() - }) - .PrimaryKey("PK_AspNetRoles", t => t.Id); - - migrationBuilder.CreateTable("AspNetRoleClaims", - c => new - { - Id = c.Int(nullable: false, identity: true), - ClaimType = c.String(), - ClaimValue = c.String(), - RoleId = c.String() - }) - .PrimaryKey("PK_AspNetRoleClaims", t => t.Id); - - migrationBuilder.CreateTable("AspNetUserClaims", - c => new - { - Id = c.Int(nullable: false, identity: true), - ClaimType = c.String(), - ClaimValue = c.String(), - UserId = c.String() - }) - .PrimaryKey("PK_AspNetUserClaims", t => t.Id); - - migrationBuilder.CreateTable("AspNetUserLogins", - c => new - { - LoginProvider = c.String(), - ProviderKey = c.String(), - ProviderDisplayName = c.String(), - UserId = c.String() - }) - .PrimaryKey("PK_AspNetUserLogins", t => new { t.LoginProvider, t.ProviderKey }); - - migrationBuilder.CreateTable("AspNetUserRoles", - c => new - { - UserId = c.String(), - RoleId = c.String() - }) - .PrimaryKey("PK_AspNetUserRoles", t => new { t.UserId, t.RoleId }); - - migrationBuilder.CreateTable("AspNetUsers", - c => new - { - Id = c.String(), - AccessFailedCount = c.Int(nullable: false), - ConcurrencyStamp = c.String(), - Email = c.String(), - EmailConfirmed = c.Boolean(nullable: false), - LockoutEnabled = c.Boolean(nullable: false), - LockoutEnd = c.DateTimeOffset(), - NormalizedEmail = c.String(), - NormalizedUserName = c.String(), - PasswordHash = c.String(), - PhoneNumber = c.String(), - PhoneNumberConfirmed = c.Boolean(nullable: false), - SecurityStamp = c.String(), - TwoFactorEnabled = c.Boolean(nullable: false), - UserName = c.String() - }) - .PrimaryKey("PK_AspNetUsers", t => t.Id); - - migrationBuilder.AddForeignKey( - "AspNetRoleClaims", - "FK_AspNetRoleClaims_AspNetRoles_RoleId", - new[] { "RoleId" }, - "AspNetRoles", - new[] { "Id" }, - cascadeDelete: false); - - migrationBuilder.AddForeignKey( - "AspNetUserClaims", - "FK_AspNetUserClaims_AspNetUsers_UserId", - new[] { "UserId" }, "AspNetUsers", - new[] { "Id" }, - cascadeDelete: false); - - migrationBuilder.AddForeignKey( - "AspNetUserLogins", - "FK_AspNetUserLogins_AspNetUsers_UserId", - new[] { "UserId" }, - "AspNetUsers", - new[] { "Id" }, - cascadeDelete: false); - } - - public override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey("AspNetRoleClaims", "FK_AspNetRoleClaims_AspNetRoles_RoleId"); - - migrationBuilder.DropForeignKey("AspNetUserClaims", "FK_AspNetUserClaims_AspNetUsers_UserId"); - - migrationBuilder.DropForeignKey("AspNetUserLogins", "FK_AspNetUserLogins_AspNetUsers_UserId"); - - migrationBuilder.DropTable("AspNetRoles"); - - migrationBuilder.DropTable("AspNetRoleClaims"); - - migrationBuilder.DropTable("AspNetUserClaims"); - - migrationBuilder.DropTable("AspNetUserLogins"); - - migrationBuilder.DropTable("AspNetUserRoles"); - - migrationBuilder.DropTable("AspNetUsers"); - } - } - - [ContextType(typeof(Models.ApplicationDbContext))] - public partial class CreateIdentitySchema : IMigrationMetadata - { - string IMigrationMetadata.MigrationId - { - get - { - return "000000000000000_CreateIdentitySchema"; - } - } - - string IMigrationMetadata.ProductVersion - { - get - { - return "7.0.0-beta2"; - } - } - - IModel IMigrationMetadata.TargetModel - { - get - { - var builder = new BasicModelBuilder(); - - builder.Entity("Microsoft.AspNet.Identity.IdentityRole", b => - { - b.Property("Id"); - b.Property("Name"); - b.Key("Id"); - b.ForRelational().Table("AspNetRoles"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.Property("ClaimType"); - b.Property("ClaimValue"); - b.Property("Id") - .GenerateValueOnAdd(); - b.Property("RoleId"); - b.Key("Id"); - b.ForRelational().Table("AspNetRoleClaims"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.Property("ClaimType"); - b.Property("ClaimValue"); - b.Property("Id") - .GenerateValueOnAdd(); - b.Property("UserId"); - b.Key("Id"); - b.ForRelational().Table("AspNetUserClaims"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.Property("LoginProvider"); - b.Property("ProviderDisplayName"); - b.Property("ProviderKey"); - b.Property("UserId"); - b.Key("LoginProvider", "ProviderKey"); - b.ForRelational().Table("AspNetUserLogins"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityUserRole`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.Property("RoleId"); - b.Property("UserId"); - b.Key("UserId", "RoleId"); - b.ForRelational().Table("AspNetUserRoles"); - }); - - builder.Entity("SampleWebAppIntegration.Models.ApplicationUser", b => - { - b.Property("AccessFailedCount"); - b.Property("ConcurrencyStamp"); - b.Property("Email"); - b.Property("EmailConfirmed"); - b.Property("Id"); - b.Property("LockoutEnabled"); - b.Property("LockoutEnd"); - b.Property("NormalizedEmail"); - b.Property("NormalizedUserName"); - b.Property("PasswordHash"); - b.Property("PhoneNumber"); - b.Property("PhoneNumberConfirmed"); - b.Property("SecurityStamp"); - b.Property("TwoFactorEnabled"); - b.Property("UserName"); - b.Key("Id"); - b.ForRelational().Table("AspNetUsers"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.ForeignKey("Microsoft.AspNet.Identity.IdentityRole", "RoleId"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.ForeignKey("SampleWebAppIntegration.Models.ApplicationUser", "UserId"); - }); - - builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => - { - b.ForeignKey("SampleWebAppIntegration.Models.ApplicationUser", "UserId"); - }); - - return builder.Model; - } - } - } -} \ No newline at end of file diff --git a/test/SampleWebAppIntegration/Migrations/ApplicationDbContextModelSnapshot.cs b/test/SampleWebAppIntegration/Migrations/ApplicationDbContextModelSnapshot.cs index 9b2618b..382ee9c 100644 --- a/test/SampleWebAppIntegration/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/test/SampleWebAppIntegration/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; +using Microsoft.Data.Entity.Metadata.Builders; using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using SampleWebAppIntegration.Models; @@ -20,7 +21,7 @@ namespace SampleWebAppIntegration.Migrations b.Property("Id"); b.Property("Name"); b.Key("Id"); - b.ForRelational().Table("AspNetRoles"); + b.Metadata.Relational().Table = "AspNetRoles"; }); builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => @@ -31,7 +32,7 @@ namespace SampleWebAppIntegration.Migrations .GenerateValueOnAdd(); b.Property("RoleId"); b.Key("Id"); - b.ForRelational().Table("AspNetRoleClaims"); + b.Metadata.Relational().Table = "AspNetRoleClaims"; }); builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => @@ -42,7 +43,8 @@ namespace SampleWebAppIntegration.Migrations .GenerateValueOnAdd(); b.Property("UserId"); b.Key("Id"); - b.ForRelational().Table("AspNetUserClaims"); + b.Metadata.Relational().Table = "AspNetUserClaims"; + }); builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => @@ -52,7 +54,7 @@ namespace SampleWebAppIntegration.Migrations b.Property("ProviderKey"); b.Property("UserId"); b.Key("LoginProvider", "ProviderKey"); - b.ForRelational().Table("AspNetUserLogins"); + b.Metadata.Relational().Table = "AspNetUserLogins"; }); builder.Entity("Microsoft.AspNet.Identity.IdentityUserRole`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => @@ -60,7 +62,7 @@ namespace SampleWebAppIntegration.Migrations b.Property("RoleId"); b.Property("UserId"); b.Key("UserId", "RoleId"); - b.ForRelational().Table("AspNetUserRoles"); + b.Metadata.Relational().Table = "AspNetUserRoles"; }); builder.Entity("SampleWebAppIntegration.Models.ApplicationUser", b => @@ -81,7 +83,7 @@ namespace SampleWebAppIntegration.Migrations b.Property("TwoFactorEnabled"); b.Property("UserName"); b.Key("Id"); - b.ForRelational().Table("AspNetUsers"); + b.Metadata.Relational().Table = "AspNetUsers"; }); builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b => diff --git a/test/SampleWebAppIntegration/Models/IdentityModels.cs b/test/SampleWebAppIntegration/Models/IdentityModels.cs index 084cf08..181eeb3 100644 --- a/test/SampleWebAppIntegration/Models/IdentityModels.cs +++ b/test/SampleWebAppIntegration/Models/IdentityModels.cs @@ -24,14 +24,14 @@ namespace SampleWebAppIntegration.Models // are supported in ASP.NET 5 if (!_created) { - Database.AsMigrationsEnabled().ApplyMigrations(); + Database.AsSqlServer().ApplyMigrations(); _created = true; } } - - protected override void OnConfiguring(DbContextOptions options) + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - options.UseSqlServer(); + optionsBuilder.UseSqlServer(this.Database.AsSqlServer().Connection.ConnectionString); } protected override void OnModelCreating(ModelBuilder builder) diff --git a/test/SampleWebAppIntegration/SampleWebAppIntegration.kproj b/test/SampleWebAppIntegration/SampleWebAppIntegration.xproj similarity index 77% rename from test/SampleWebAppIntegration/SampleWebAppIntegration.kproj rename to test/SampleWebAppIntegration/SampleWebAppIntegration.xproj index cf54086..5f19c35 100644 --- a/test/SampleWebAppIntegration/SampleWebAppIntegration.kproj +++ b/test/SampleWebAppIntegration/SampleWebAppIntegration.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 330152ec-1092-41f0-9f96-c3438e07fcc2 SampleWebAppIntegration @@ -15,5 +14,9 @@ 2.0 54056 - + + True + + + \ No newline at end of file diff --git a/test/SampleWebAppIntegration/Startup.cs b/test/SampleWebAppIntegration/Startup.cs index fa95b56..6040c7d 100644 --- a/test/SampleWebAppIntegration/Startup.cs +++ b/test/SampleWebAppIntegration/Startup.cs @@ -1,16 +1,17 @@ -using FunctionalTestUtils; +using System; +using FunctionalTestUtils; using Microsoft.ApplicationInsights.AspNet; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics.Entity; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Identity; +using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; using Microsoft.Framework.Logging.Console; using SampleWebAppIntegration.Models; -using System; namespace SampleWebAppIntegration { @@ -19,7 +20,7 @@ namespace SampleWebAppIntegration public Startup(IHostingEnvironment env) { // Setup configuration sources. - Configuration = new Configuration() + Configuration = new Configuration(".") .AddJsonFile("config.json") .AddEnvironmentVariables(); } @@ -33,12 +34,12 @@ namespace SampleWebAppIntegration services.AddApplicationInsightsTelemetry(Configuration); // Add EF services to the services container. - services.AddEntityFramework(Configuration) + services.AddEntityFramework() .AddSqlServer() .AddDbContext(); // Add Identity services to the services container. - services.AddIdentity(Configuration) + services.AddIdentity() .AddEntityFrameworkStores(); // Add MVC services to the services container. @@ -64,7 +65,7 @@ namespace SampleWebAppIntegration // Add the following to the request pipeline only in development environment. if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { - app.UseBrowserLink(); + //app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll); // Set immediate delivery for Application Insights events. diff --git a/test/SampleWebAppIntegration/Views/Account/_ChangePasswordPartial.cshtml b/test/SampleWebAppIntegration/Views/Account/_ChangePasswordPartial.cshtml index 9fca583..5bb836f 100644 --- a/test/SampleWebAppIntegration/Views/Account/_ChangePasswordPartial.cshtml +++ b/test/SampleWebAppIntegration/Views/Account/_ChangePasswordPartial.cshtml @@ -1,7 +1,7 @@ @using System.Security.Principal @model SampleWebAppIntegration.Models.ManageUserViewModel -

You're logged in as @User.Identity.GetUserName().

+

You're logged in as @User.Identity.Name.

@using (Html.BeginForm("Manage", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) { diff --git a/test/SampleWebAppIntegration/Views/Shared/_LoginPartial.cshtml b/test/SampleWebAppIntegration/Views/Shared/_LoginPartial.cshtml index 0ec8621..8823077 100644 --- a/test/SampleWebAppIntegration/Views/Shared/_LoginPartial.cshtml +++ b/test/SampleWebAppIntegration/Views/Shared/_LoginPartial.cshtml @@ -7,7 +7,7 @@ @Html.AntiForgeryToken() diff --git a/test/SampleWebAppIntegration/project.json b/test/SampleWebAppIntegration/project.json index 5cd1708..d457706 100644 --- a/test/SampleWebAppIntegration/project.json +++ b/test/SampleWebAppIntegration/project.json @@ -3,28 +3,28 @@ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { - "EntityFramework.SqlServer": "7.0.0-beta3", - "EntityFramework.Commands": "7.0.0-beta3", - "Microsoft.AspNet.Mvc": "6.0.0-beta3", - /* "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3", */ - "Microsoft.AspNet.Diagnostics": "1.0.0-beta3", - "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta3", - "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta3", - "Microsoft.AspNet.Security.Cookies": "1.0.0-beta3", - "Microsoft.AspNet.Server.IIS": "1.0.0-beta3", - "Microsoft.AspNet.Server.WebListener": "1.0.0-beta3", - "Microsoft.AspNet.StaticFiles": "1.0.0-beta3", - "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3", - "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta3", - "Microsoft.Framework.Logging": "1.0.0-beta3", - "Microsoft.Framework.Logging.Console": "1.0.0-beta3", + "EntityFramework.SqlServer": "7.0.0-beta5-*", + "EntityFramework.SqlServer.Design": "7.0.0-beta5-*", + "EntityFramework.Core": "7.0.0-beta5-*", + "EntityFramework.Commands": "7.0.0-beta5-*", + "Microsoft.AspNet.Mvc": "6.0.0-beta5-*", + "Microsoft.AspNet.Diagnostics": "1.0.0-beta5-*", + "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5-*", + "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5-*", + "Microsoft.AspNet.Server.IIS": "1.0.0-beta5-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5-*", + "Microsoft.AspNet.StaticFiles": "1.0.0-beta5-*", + "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-*", + "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5-*", + "Microsoft.Framework.Logging": "1.0.0-beta5-*", + "Microsoft.Framework.Logging.Console": "1.0.0-beta5-*", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta3", - "ApplicationInsights.AspNet": "0.30.0.1-beta", + "Microsoft.ApplicationInsights.AspNet": "0.30.0.1-beta", "FunctionalTestUtils": "1.0.0-*", - "xunit": "2.1.0.0-beta1-build2945", - "xunit.runner.aspnet": "2.1.0.0-beta1-build60", - "xunit.runner.visualstudio": "2.1.0.0-beta1-build1051", - "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3" + "xunit.runner.aspnet": "2.0.0-aspnet-beta5-*", + "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5-*", + "System.Runtime": "4.0.20-beta-*", + "Microsoft.Framework.Runtime": "1.0.0-beta5-*" }, "commands": { /* Change the port number when you are self hosting this application */ @@ -34,15 +34,18 @@ "test": "xunit.runner.aspnet" }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } + "dnx451": { + "dependencies": { + "System.Runtime": "4.0.20-beta-*" + } + } }, "exclude": [ "wwwroot", "node_modules", "bower_components" ], - "bundleExclude": [ + "publishExclude": [ "node_modules", "bower_components", "**.kproj",