How to unit test UWP App with Azure Mobile App? - unit-testing

Consider a Visual Studio 2017 solution with 3 projects:
UWPApp - Universal Windows App
UWPAppTest - Universal Windows App Test (NuGet package: Microsoft.Azure.Mobile.Client)
MobileApp - Azure Mobile App web service (NuGet package: Microsoft.Azure.Mobile.Server)
I'd like to create a unit test in my UWPAppTest project, that calls my web service, running locally in my MobleApp web service project.
This requires me to somehow configure Visual Studio to launch the MobileApp project (selecting "don't open a page"). And at the same time, click "Debug Selected Test" in my test explorer. Or, somehow automatically launch the MobileApp in debug mode, when I debug a unit test.
This doesn't look like a supported scenario, and if not, what would be the next best workaround to be able to run a UWP test project, with tests calling a local web service?
Thanks
-John

This is something that Azure Mobile Apps has had to deal with as well. We use end-to-end test scenarios with a mobile backend hosted in the cloud. The test run will clear the contents of the database prior to each run, thus ensuring the appropriate unit testing. The biggest thing here is dealing with state.
In a local debug version, you will want to set the URI passed into the MobileServicesClient to your localhost, but things should not be any different. Just ensure you are fixing the starting point and ending point of your database for each test.

Related

Project Type for simple headless windows application

I am creating a Windows app that will run on Windows 2012r2 and soon be migrated to newer servers.
This app will be started from task scheduler and run several times a day.
It will start up, monitor a file system and, based on what it finds on the file system, will update a database.
I want it to run even when the user is not logged in.
I don't want it to pop up a console window while it is running because I inherited some applications that are doing that and it is quite annoying.
I will be writing it in C#.
In Visual Studio 2017 which project type should I choose?
Blank App
WPF App
Console App (.NET Core)
Console App (.NET Framework)
Other?
I am new to Windows development so please use terminology that I will see in Visual Studio 2017 so I can understand the answer.
[EDIT] I changed Console App (.Net Standard) to (.Net Framework) because Standard does not exist. I was suffering from temporary insanity when I listed that as an option.
Since there is no user interface, and you are just monitoring the file system and updating a database and running on a Window Server I would recommend:
4. Console App (.NET Framework), and in the Application/Properties for the app set the output type to Windows application and this will prevent any type of console window from showing. This is the type of application I use on a frequent basis to accomplish tasks very similar to what you are describing. The security settings you have for the user account logging into the server will determine if you can run it whether the user is logged in or not.

How to correctly do unit testing with this configuration

I've got a WPF solution that interacts with Webservices in order to retrieve data.
My application is divided in modules for manteinability and there's a 1:1 correnspondency between WPF modules and Web service's part. I use ServiceStack as layer to perform web service call and my WPF modules use repository pattern to isolate calls.
WPF assemblies are compiled with FW 4.0 (since it has to bee used on XP also) meanwhile Web are FW 4.5.2
I was wondering what's the best solution to debug such repositories without the need to have a Web server configured for this purpose. In my mind if I've the possibility to run both on 4.5.2 I would set up a self-hosted webservice that loads the web module and performs call without having the need to have a web server configured for that... any suggestion/proposal on that?

ASP.NET Web Service returning Bad Request in Windows Azure

After a Windows 7 fresh restart, I open the Visual Studio 2010 as administrator, create a new project of Windows Azure Project with ASP.NET Web Role, then at the WebRole1 project I add a WebService1.asmx and press F5 (run).
The Windows Azure services starts OK and the browser open the http:/127.0.0.1:8080/WebService1.asmx perfectly. But when I click at Invoke button to test the webservice method I always receive a Bad Request - Invalid Hostname, with a http:/127.0.0.1:8081/WebService1.asmx/HelloWorld.
The most likely cause is ASMX's WSDL file doesn't stand by load balanced environment such as Windows Azure. The test feature relies on WSDL. You will see similar issues if you add a web/service reference. It is recommended to upgrade to WCF. In WCF, you can use useRequestHeadersForMetadataAddress (http://msdn.microsoft.com/en-us/library/ee816894.aspx) to fix the issue. If you need to use ASMX, please try to manually provide a correct WSDL file.

Is it possible to debug locally WebService on Google App Engine

I am new on web services development and I will be using the app engine.
I would like to know if it is possible to debug locally a web service (at localhost:8888/) and debug at the same time the web app that will be using the service.
The App Engine SDK ships with a local server implementation that you typically debug on. You'd debug the web app in your browser.
http://code.google.com/appengine/docs/python/tools/devserver.html
Yes, you can debug both client and server.
However I assume that client and server are separate code bases - in this case you would have two IDE projects open each running it's own debug session.
Since you are new to GAE, I would advice to use one of rich IDE's available out there. For example, I can mention Eclipse or IntelliJ which make it very easy to debug and find issues in GAE apps.
Here are some links:
Intellij GAE support
Eclypse GAE plugin

ASMX + external dll

I am working on Silverlight client to Microsoft Team Foundation Server. I am using an ASMX web service to make the actual calls using the TFS api.
Everything works fine when I run it with the visual studio development server, but I cannot figure out how to deploy the app to IIS.
I can get the ASMX web service to work unless it is a call that uses the TFS api. I have tried putting all of the TFS api DLLs in like every directory that I can think of, and even installing the visual studio sdk. Nothing works!
UPDATE 11/15/09 7:50PM EST:
Turns out that the TFS api was trying to create a cache at c:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\, and the IIS_WPG user didn't have access to do so. Easy fix.
The only supported way of installing the TFS API is to install Team Explorer. You could try to GAC just the assemblies you need, but you're on your own [and technically violating the EULA]...
Other things to check:
IIS is running in 32 bit mode
Impersonation is working correctly
Proxy settings
What error do you get? Have you tried attaching a debugger to IIS?