alexanderzeitler.com - Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4









Search Preview

Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4 | Alexander Zeitler

alexanderzeitler.com

.com > alexanderzeitler.com

SEO audit: Content analysis

Language Error! No language localisation is found.
Title Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4 | Alexander Zeitler
Text / HTML ratio 55 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud unknown>0 = Kestrel AspNet5IntegrationTesting var public ASPNET serverFactoryLocation DNX bootstrapping host test tests MicrosoftAspNetServerWebListener xunit MicrosoftAspNetStaticFiles xunitrunnerdnx xunitrunnervisualstudio MicrosoftAspNetServerIIS
Keywords consistency
Keyword Content Title Description Headings
18
unknown>0 18
= 17
Kestrel 6
AspNet5IntegrationTesting 6
var 5
Headings
H1 H2 H3 H4 H5 H6
1 0 0 0 0 0
Images We found 0 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
18 0.90 %
unknown>0 18 0.90 %
= 17 0.85 %
Kestrel 6 0.30 %
AspNet5IntegrationTesting 6 0.30 %
var 5 0.25 %
public 5 0.25 %
ASPNET 4 0.20 %
serverFactoryLocation 4 0.20 %
DNX 4 0.20 %
bootstrapping 4 0.20 %
host 4 0.20 %
test 4 0.20 %
tests 4 0.20 %
MicrosoftAspNetServerWebListener 4 0.20 %
xunit 3 0.15 %
MicrosoftAspNetStaticFiles 3 0.15 %
xunitrunnerdnx 3 0.15 %
xunitrunnervisualstudio 3 0.15 %
MicrosoftAspNetServerIIS 3 0.15 %

SEO Keywords (Two Word)

Keyword Occurrence Density
in 18 0.90 %
0 18 0.90 %
unknown>0 at 16 0.80 %
= new 4 0.20 %
MicrosoftAspNetStaticFiles 100beta4 3 0.15 %
MicrosoftAspNetServerWebListener 100beta4 3 0.15 %
bootstrapping a 3 0.15 %
210beta2build79 xunitrunnervisualstudio 3 0.15 %
xunitrunnerdnx 210beta2build79 3 0.15 %
210 xunitrunnerdnx 3 0.15 %
xunit 210 3 0.15 %
100beta4 MicrosoftAspNetStaticFiles 3 0.15 %
MicrosoftAspNetServerIIS 100beta4 3 0.15 %
100beta4 MicrosoftAspNetServerWebListener 3 0.15 %
serverFactoryLocation = 3 0.15 %
600beta4 MicrosoftAspNetServerIIS 3 0.15 %
MicrosoftAspNetMvc 600beta4 3 0.15 %
ASPNET 5 3 0.15 %
to our 3 0.15 %
xunitrunnervisualstudio 210beta1build1051 3 0.15 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
in 0 18 0.90 % No
0 at 16 0.80 % No
MicrosoftAspNetServerIIS 100beta4 MicrosoftAspNetServerWebListener 3 0.15 % No
210 xunitrunnerdnx 210beta2build79 3 0.15 % No
210beta2build79 xunitrunnervisualstudio 210beta1build1051 3 0.15 % No
xunitrunnerdnx 210beta2build79 xunitrunnervisualstudio 3 0.15 % No
600beta4 MicrosoftAspNetServerIIS 100beta4 3 0.15 % No
xunit 210 xunitrunnerdnx 3 0.15 % No
MicrosoftAspNetMvc 600beta4 MicrosoftAspNetServerIIS 3 0.15 % No
100beta4 MicrosoftAspNetStaticFiles 100beta4 3 0.15 % No
MicrosoftAspNetServerWebListener 100beta4 MicrosoftAspNetStaticFiles 3 0.15 % No
100beta4 MicrosoftAspNetServerWebListener 100beta4 3 0.15 % No
dependencies MicrosoftAspNetMvc 600beta4 2 0.10 % No
MicrosoftAspNetWebApiClient 523 xunit 2 0.10 % No
projectjson file dependencies 2 0.10 % No
our projectjson file 2 0.10 % No
unknown>0 at MicrosoftAspNetServerKestrelDisposableDispose 2 0.10 % No
IntPtr value in 2 0.10 % No
value in 2 0.10 % No
to our projectjson 2 0.10 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
in 0 at 16 0.80 % No
MicrosoftAspNetServerIIS 100beta4 MicrosoftAspNetServerWebListener 100beta4 3 0.15 % No
MicrosoftAspNetMvc 600beta4 MicrosoftAspNetServerIIS 100beta4 3 0.15 % No
600beta4 MicrosoftAspNetServerIIS 100beta4 MicrosoftAspNetServerWebListener 3 0.15 % No
MicrosoftAspNetServerWebListener 100beta4 MicrosoftAspNetStaticFiles 100beta4 3 0.15 % No
xunitrunnerdnx 210beta2build79 xunitrunnervisualstudio 210beta1build1051 3 0.15 % No
210 xunitrunnerdnx 210beta2build79 xunitrunnervisualstudio 3 0.15 % No
xunit 210 xunitrunnerdnx 210beta2build79 3 0.15 % No
100beta4 MicrosoftAspNetServerWebListener 100beta4 MicrosoftAspNetStaticFiles 3 0.15 % No
dependencies MicrosoftAspNetMvc 600beta4 MicrosoftAspNetServerIIS 2 0.10 % No
bootstrapping a self host 2 0.10 % No
projectjson file dependencies MicrosoftAspNetMvc 2 0.10 % No
0 at MicrosoftAspNetServerKestrelDisposableDispose 2 0.10 % No
our projectjson file dependencies 2 0.10 % No
to our projectjson file 2 0.10 % No
value in 0 2 0.10 % No
IntPtr value in 2 0.10 % No
100beta4 MicrosoftAspNetStaticFiles 100beta4 MicrosoftAspNetWebApiClient 2 0.10 % No
MicrosoftAspNetStaticFiles 100beta4 MicrosoftAspNetWebApiClient 523 2 0.10 % No
file dependencies MicrosoftAspNetMvc 600beta4 2 0.10 % No

Internal links in - alexanderzeitler.com

Fixing Chrome 58+ [missing_subjectAltName] with openssl when using self signed certificates
Fixing Chrome 58+ [missing_subjectAltName] with openssl when using self signed certificates | Alexander Zeitler
Accessing an HTTP API running on your MacBook in a Docker container from your iPhone/iPad using dnsmasq
Accessing an HTTP API running on your MacBook in a Docker container from your iPhone/iPad using dnsmasq | Alexander Zeitler
Deploying Ubuntu Mate Desktop as a developer environment in a Azure VM
Deploying Ubuntu Mate Desktop as a developer environment in a Azure VM | Alexander Zeitler
Deploying Ubuntu Mate Desktop as a developer environment in AWS EC2
Deploying Ubuntu Mate Desktop as a developer environment in AWS EC2 | Alexander Zeitler
Debugging mocha tests in a Docker container using Visual Studio Code
Debugging mocha tests in a Docker container using Visual Studio Code | Alexander Zeitler
Debugging mocha tests with Visual Studio Code when Node.js is installed using nvm
Debugging mocha tests with Visual Studio Code when Node.js is installed using nvm | Alexander Zeitler
Debugging a ES6 Node.js application in a Docker container using Visual Studio Code
Debugging a ES6 Node.js application in a Docker container using Visual Studio Code | Alexander Zeitler
Some thoughts on Open Source Software
Some thoughts on Open Source Software | Alexander Zeitler
Resizing a VMware Workstation VM partition using GParted - get the swap partition out of my way!
Resizing a VMware Workstation VM partition using GParted - get the swap partition out of my way! | Alexander Zeitler
Workflows: using Docker Machine and Docker Compose together in development
Workflows: using Docker Machine and Docker Compose together in development | Alexander Zeitler
Chrome crashes on Ubuntu in VMware Workstation
Chrome crashes on Ubuntu in VMware Workstation | Alexander Zeitler
Rename Visual Studio project including files, folders and namespaces
Rename Visual Studio project including files, folders and namespaces | Alexander Zeitler
A lap around AWS and docker-machine
A lap around AWS and docker-machine | Alexander Zeitler
Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4
Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4 | Alexander Zeitler
Deploying a ASP.NET MVC 6 API as Azure API App in Azure App Services
Deploying a ASP.NET MVC 6 API as Azure API App in Azure App Services | Alexander Zeitler
lowerCamelCase JSON with ASP.NET MVC 6
lowerCamelCase JSON with ASP.NET MVC 6 | Alexander Zeitler
Running ASP.NET 5 Beta 4 in Docker with DNX runtime #aspnet5 #docker
Running ASP.NET 5 Beta 4 in Docker with DNX runtime #aspnet5 #docker | Alexander Zeitler
Stop complaining or improve yourself
Stop complaining or improve yourself | Alexander Zeitler
#NodeJS / #ExpressJS: Adding routes dynamically at runtime
#NodeJS / #ExpressJS: Adding routes dynamically at runtime | Alexander Zeitler
mongoose: Referencing schema in properties or arrays
mongoose: Referencing schema in properties or arrays | Alexander Zeitler
MongoDB development environment journal size management using mongoctl
MongoDB development environment journal size management using mongoctl | Alexander Zeitler
Farewell...
Farewell... | Alexander Zeitler
Inspecting AngularJS $scope using Firebug and Chrome Developer Tools
Inspecting AngularJS $scope using Firebug and Chrome Developer Tools | Alexander Zeitler
Useful @Brackets extensions for Web Developers
Useful @Brackets extensions for Web Developers | Alexander Zeitler
.NET User Group Karlsruhe: StreamInsight: Complex Event Processing by Microsoft
.NET User Group Karlsruhe: StreamInsight: Complex Event Processing by Microsoft | Alexander Zeitler
“Commit all must be called when a managed buffer has focus” in Microsoft SQL Server Data Tools
“Commit all must be called when a managed buffer has focus” in Microsoft SQL Server Data Tools | Alexander Zeitler
.NET User Group Karlsruhe: Git
.NET User Group Karlsruhe: Git | Alexander Zeitler
Open Source Windows 8 App: Sprudelsuche
Open Source Windows 8 App: Sprudelsuche | Alexander Zeitler
Open Source– Scheissegal?
Open Source– Scheissegal? | Alexander Zeitler
Lowercase JSON with ASP.NET Web API
Lowercase JSON with ASP.NET Web API | Alexander Zeitler
.NET Usergroup Karlsruhe: Think Big – Entwicklung skalierbarer Anwendungen mit Windows Azure
.NET Usergroup Karlsruhe: Think Big – Entwicklung skalierbarer Anwendungen mit Windows Azure | Alexander Zeitler
ASP.NET Web API and RavenDb
ASP.NET Web API and RavenDb | Alexander Zeitler
ASP.NET Web API Round-Up Slides
ASP.NET Web API Round-Up Slides | Alexander Zeitler
ASP.NET MVC 4 public beta including ASP.NET Web API
ASP.NET MVC 4 public beta including ASP.NET Web API | Alexander Zeitler
Hash Bang Urls in Single Page Applications mit ASP.NET MVC
Hash Bang Urls in Single Page Applications mit ASP.NET MVC | Alexander Zeitler
.NET User Group Karlsruhe: Know your Tools
.NET User Group Karlsruhe: Know your Tools | Alexander Zeitler
Git flow init liefert: flags: FATAL unable to determine getopt version unter Cygwin
Git flow init liefert: flags: FATAL unable to determine getopt version unter Cygwin | Alexander Zeitler
Using JsonValue and JsonArray in WCF Web API
Using JsonValue and JsonArray in WCF Web API | Alexander Zeitler
.NET User Group Karlsruhe: PowerShell 3.. 2.. 1..
.NET User Group Karlsruhe: PowerShell 3.. 2.. 1.. | Alexander Zeitler
What’s new in WCF Web API Preview 5 – introducing the test client
What’s new in WCF Web API Preview 5 – introducing the test client | Alexander Zeitler
Externe Templates in KnockoutJS laden
Externe Templates in KnockoutJS laden | Alexander Zeitler
WCF Web API: Role based access control with basic authentication
WCF Web API: Role based access control with basic authentication | Alexander Zeitler
.NET User Group Karlsruhe: Produce Cleaner Code with Aspect-Oriented Programming (AOP)
.NET User Group Karlsruhe: Produce Cleaner Code with Aspect-Oriented Programming (AOP) | Alexander Zeitler
REST using the WCF Web API – POST it!
REST using the WCF Web API – POST it! | Alexander Zeitler
REST using the WCF Web API – getting more RESTful responses (Part 5)
REST using the WCF Web API – getting more RESTful responses (Part 5) | Alexander Zeitler
TypeLoadException when mocking COM objects - Could not load type … from assembly. The type is marked…
TypeLoadException when mocking COM objects - Could not load type … from assembly. The type is marked… | Alexander Zeitler
REST using the WCF Web API – getting RESTful the BDD way (Part 4)
REST using the WCF Web API – getting RESTful the BDD way (Part 4) | Alexander Zeitler
REST using the WCF Web API – refactoring to IoC style (Part 3)
REST using the WCF Web API – refactoring to IoC style (Part 3) | Alexander Zeitler
REST using the WCF Web API – Basics (Part2)
REST using the WCF Web API – Basics (Part2) | Alexander Zeitler
Microsoft Web API – the REST is done by WCF (Part 1)
Microsoft Web API – the REST is done by WCF (Part 1) | Alexander Zeitler
Microsoft Web API – den REST macht WCF (Teil 1)
Microsoft Web API – den REST macht WCF (Teil 1) | Alexander Zeitler
.NET User Group Karlsruhe: Flexible Softwarearchitekturen mit Inversion of Control (IoC)
.NET User Group Karlsruhe: Flexible Softwarearchitekturen mit Inversion of Control (IoC) | Alexander Zeitler
machine.fakes ReSharper Templates
machine.fakes ReSharper Templates | Alexander Zeitler
CreateCert.cmd aus dem Windows Azure Platform Training Kit funktioniert nicht
CreateCert.cmd aus dem Windows Azure Platform Training Kit funktioniert nicht | Alexander Zeitler
JSON via jQuery direkt an einen ASP.NET MVC 3 Controller senden
JSON via jQuery direkt an einen ASP.NET MVC 3 Controller senden | Alexander Zeitler
POSTing Json data using the HttpClient from WCF Web API
POSTing Json data using the HttpClient from WCF Web API | Alexander Zeitler
Using the new WCF Web APIs HttpClient with ASP.NET Forms Authentication
Using the new WCF Web APIs HttpClient with ASP.NET Forms Authentication | Alexander Zeitler
Keyboard Jedi unter x64
Keyboard Jedi unter x64 | Alexander Zeitler
Using WCF Web APIs / WCF Http with ASP.NET Forms Authentication
Using WCF Web APIs / WCF Http with ASP.NET Forms Authentication | Alexander Zeitler
WCF Web APIs / WCF Http mit ASP.NET Forms Authentication verwenden
WCF Web APIs / WCF Http mit ASP.NET Forms Authentication verwenden | Alexander Zeitler
ILSpy – Open Source .NET Assembly Browser und Decompiler
ILSpy – Open Source .NET Assembly Browser und Decompiler | Alexander Zeitler

Alexanderzeitler.com Spined HTML


Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4 | Alexander Zeitler Toggle navigation Home Feed Integration-testing ASP.NET 5 / MVC 6 Controllers on DNX Beta 4 Written on May 16, 2015 In ASP.NET 5 bootstrapping a self host test server has reverted compared to ASP.NET 4 / Web API. This post will show you how you can run integration tests using ASP.NET 5 / MVC 6 API Controllers on Beta 4 of DNX. First, the Controller implementation: CustomersController.cs: [Route("api/[controller]")] public matriculation CustomersController { [HttpGet] public IActionResult GetAll() { return new ObjectResult( new List<Customer>() { new Customer { CompanyName = "PDMLab", AddressLine = "Ludwig-Erhard-Allee 10", ZipCode = "76131", City = "Karlsruhe", Website = "https://pdmlab.com" } }); } } Our tests will use Xunit, so we'll add Xunit to our project.json file: ... "dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.StaticFiles": "1.0.0-beta4", "xunit": "2.1.0-*", "xunit.runner.dnx": "2.1.0-beta2-build79", "xunit.runner.visualstudio": "2.1.0-beta1-build1051" }, ... Furthermore, our HttpClient we're using resides in Microsoft.AspNet.WebApi.Client which we'll add moreover to our project.json file: ... "dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.StaticFiles": "1.0.0-beta4", "Microsoft.AspNet.WebApi.Client": "5.2.3", "xunit": "2.1.0-*", "xunit.runner.dnx": "2.1.0-beta2-build79", "xunit.runner.visualstudio": "2.1.0-beta1-build1051" }, ... Finally, we need Kestrel to run our tests on *nix based systems as well as Microsoft.AspNet.Hosting which contains the classes required for bootstrapping a self host server - : ... "dependencies": { "Kestrel": "1.0.0-beta4", "Microsoft.AspNet.Hosting": "1.0.0-beta4", "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.StaticFiles": "1.0.0-beta4", "Microsoft.AspNet.WebApi.Client": "5.2.3", "xunit": "2.1.0-*", "xunit.runner.dnx": "2.1.0-beta2-build79", "xunit.runner.visualstudio": "2.1.0-beta1-build1051" }, ... The final part required is the test itself: public matriculation CustomerControllerIntegrationTest { [Fact] public void ShouldReturnCustomer() { var config = new Configuration(); config.AddCommandLine(new[] { "--server.urls", "http://localhost:5001" }); var serverFactoryLocation = string.Empty; if(!IsMono()) { serverFactoryLocation = "Microsoft.AspNet.Server.WebListener"; } else { serverFactoryLocation = "Kestrel"; } var context = new HostingContext() { Configuration = config, ServerFactoryLocation = serverFactoryLocation, ApplicationName = "AspNet5IntegrationTesting", StartupMethods = new StartupMethods(builder => builder.UseMvc(), services => { services.AddMvc(); return services.BuildServiceProvider(); }) }; using (new HostingEngine().Start(context)) { var vendee = new HttpClient(); var customers = client.GetAsync("http://localhost:5001/api/customers").Result .Content.ReadAsAsync<List<Customer>>().Result; Assert.Equal(customers[0].CompanyName,"PDMLab"); } } public static bool IsMono() { return Type.GetType("Mono.Runtime") != null; } } The implementation is pretty straight forward: First we're subtracting the host and port our test server should listen on to our using configuration. Then we're checking if we're running on mono and depdending on the result, we're bootstrapping Kestrel oder WebListener.Withoutthat we're bootstrapping a HostingContext instance which configures our StartupMethods (which contains the stuff that resides in your Startup.cs normally), Configuration and the host to use. Using this context we're firing up a new HostingEngine instance which gets disposedd without the assertions have finished. That's it... almost, considering there's one caveat: The tests currently goof on Kestrel / *nix with this error: xUnit.net DNX test runner (64-bit DNX 4.5.1) Copyright (C) 2015 Outercurve Foundation. Discovering: AspNet5IntegrationTesting Discovered: AspNet5IntegrationTesting Starting: AspNet5IntegrationTesting AspNet5IntegrationTesting.Tests.CustomerControllerIntegrationTest.ShouldReturnCustomer [FAIL] System.ArgumentException : GCHandle value belongs to a variegated domain Stack Trace: at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) [0x00000] in <filename unknown>:0 at System.Runtime.InteropServices.GCHandle.FromIntPtr (IntPtr value) [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.Networking.UvMemory.DestroyMemory (IntPtr memory) [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.Networking.UvLoopHandle.ReleaseHandle () [0x00000] in <filename unknown>:0 at System.Runtime.InteropServices.SafeHandle.RunRelease () [0x00000] in <filename unknown>:0 at System.Runtime.InteropServices.SafeHandle.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 at System.Runtime.InteropServices.SafeHandle.Dispose () [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.KestrelThread.ThreadStart (System.Object parameter) [0x00000] in <filename unknown>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.KestrelThread.Stop (TimeSpan timeout) [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.KestrelEngine.Dispose () [0x00000] in <filename unknown>:0 at Kestrel.ServerFactory+<>c__DisplayClass3_0.<Start>b__1 () [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.Disposable.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.Disposable.Dispose () [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Hosting.HostingEngine+<>c__DisplayClass9_0.<Start>b__1 () [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Hosting.HostingEngine+Disposable.Dispose () [0x00000] in <filename unknown>:0 at AspNet5IntegrationTesting.Tests.CustomerControllerIntegrationTest.ShouldReturnCustomer () [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 Finished: AspNet5IntegrationTesting === TEST EXECUTION SUMMARY === AspNet5IntegrationTesting Total: 1, Errors: 0, Failed: 1, Skipped: 0, Time: 0.697s If somebody has an idea well-nigh this, please send me a pull request at GitHub (yes, you can grab the source over there) ;-) Update [2015/05/17]: This is a known Kestrel issue as described here (Description starts here) and a fix is on the way. Please enable JavaScript to view the comments powered by Disqus. Copyright © Alexander Zeitler 2003 - 2016 | Impressum