Running Visual Studio for Mac 17.4.2 (build 17)
I have a unit test that uses core WCF to call a web service at: https://www.dataaccess.com/webservicesserver/NumberConversion.wso
This works fine when I run the test if I have the ProxyMan app running. However, without ProxyMan I get a timeout after one minute.
In order to generate the wcf proxy class, I ran the following against my unit test project:
dotnet tool install --global dotnet-svcutil
dotnet-svcutil --roll-forward LatestMajor https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL
This generated a large reference.cs file - which I've copied here
My unit test that calls into this can be seen below:
[Fact]
public async Task CanConvertNumber()
{
var client = new NumberConversionSoapTypeClient(NumberConversionSoapTypeClient.EndpointConfiguration.NumberConversionSoap,
"https://www.dataaccess.com/webservicesserver/NumberConversion.wso");
var response = await client.NumberToWordsAsync(46);
Trace.WriteLine($"The response is: {response.Body.NumberToWordsResult}");
response.Body.Should().Equals("Forty Six");
}
I have now created a simple console app to reproduce what I have in the unit test. The code for this can be found at: https://github.com/RobBowman/core-wcf-client
Any ideas why it could be dependent on proxyman? It seems as if core wcf code is routing to localhost for some reason.
Thanks,
Rob.
Related
I`m using VS 2022 Professional 2022 (17.2.0).
I wanted to create a ASP.Net Core app with Angular in VS and used the Microsoft Tutorial for it. https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022
When I want to start Multiple Project as once, only Angular CLI will start the ng start command, but the ASP.NET Core Project will never start.
When I disable the Angular Project inside, Multiple Startprojects, the .Net Core Console will start.
Creation started...
1>------ Build started: Project: ConverterBackend, Configuration: Debug Any CPU ------
2>------ Build started: Project: Converter, Configuration: Debug Any CPU ------
1>Analyzer tools are skipped to speed up the build. You can run the Build or Rebuild command to run the analyzer.
1>ConverterBackend -> C:\Optimization\Converter\ConverterBackend\bin\Debug\net6.0\ConverterBackend.dll
3>------ Deployment started: Project: Converter, Configuration: Debug Any CPU ------
Settings:
proxy.conf.js
target: "https://localhost:7049",
launchSettings.json
"applicationUrl": "https://localhost:7049;https://localhost:5001",
I hope somebody has a Solution or run into the same Error once, cause I cant find anything about this.
Could this be an AV problem?
Solution:
If u ever run into this Problem Check Script Execution permissions and if the AV blocks something.
I was also struggling with this and finally found a solution thanks to this user. It might not be viable for everyone since it requires a version downgrade but I'll share it: I was using Node.js v18.12.1 (LTS at the time) (64-bit). I had installed it with nvm for Windows. With this set up, OP problem is reproduced.
Then, I used nvm to switch to Node v16.18.1 (64-bit). With this change the frontend and backend run perfect as expected from the tutorial.
Edit:
Another solution to avoid the downgrade is keep using Node.js v18.12.1 and just add --host 0.0.0.0 to the start command in Angular package.json:
"start": "ng serve --host 0.0.0.0 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key"
This works but I can't provide an explanation for why. But it requires adding a rule to the Windows firewall (you probably get a prompt asking you for permission).
You have to start the ASP.Net Core app. In there you should have a Startup Class.
Go to Configure Services and add something like this:
services.AddSpaStaticFiles(configuration => { configuration.RootPath = "WebUI"; });
Then the Kestrel Server should start up with the SPA.
I use two instances of VS open for this; each with a different start up project.
I am currently working on C# selenium automation tests. My setup is simple: running tests on a test server (accessible via remote desktop), I've setup task scheduler trigger to run them every day via this command:
dotnet test --logger:"html;LogFileName=C:\inetpub\wwwroot\mywebsite\TestResults\TestResults.html" C:\AutomationSuite\Testsuite.dll
The test results output file is stored in a wwwroot foolder and is uploaded to a website that is accessible via vpn.
Visible output:
Now, my question is: are there any extensions or convertors for my test results to be more appealing to the eye? Like in a pie chart or something like that (running on azure devops the output of test run is more appealing).
Is it possible or am I digging too deep?
Much appreciated
Managed to set it up using AllureReport
I have a MVC project which uses the application insight and it is working fine and it is capturing all the telemetric details in azure under the proper dashboard.
I am trying to test this functionality through the unit test project, from the unit test project i am calling the class file which is present in the MVC project.,
It is working and executing the the Funciton1() but these values are not diaplaying under the dashboard...
Any suggestions..
Application 1 -> Testproject C# Class project
[TestMethod]
Method1()
{
MVCAppinsightCls a = new MVCAppinsightCls();
a.Function1();
}
MVC WebApplication
Class MVCAppinsightCls
{
Funciton1()
{
TelemetryClient o = new TelemetryClient();
o.trackEvent("someName");
}
}
When you run the method like this from your Test project, then your Test project is your host so what you need is to add all the configurations related to your App Insights in your Test Peoject too (Instumentation Key settings and all other stuff) so that it sends the logs to App Insights.
You need the ApplicationInsights.config file and also you need to add the nuget packages related to App Insights to your Unit Test project.
I have an existing ASP.NET application with few ashx and asmx services. How can I host them from console (or specifically from tests) for integration testing purposes?
Developers use IIS Express to run and debug them locally, so it's not an option to start IIS Express for that.
It is enough for me to skip the whole pipeline and invoke them directly, if possible.
You don't have to test web server, you can assume it's been tested by Microsoft and working fine, but you can test only your handler by invoking it from unit test. Take a look here (Example #2) how to provider a fake HttpContext to your ProcessRequest handler method. Also, try this fake HttpContext:
HttpContext.Current = new HttpContext(
new HttpRequest(null, "http://tempuri.org", null),
new HttpResponse(null));
For full end-to-end acceptance test you'll have to spin up IIS Express or even Casini server with command line:
START /D “C:\Program Files\Common Files\microsoft shared\DevServer\9.0\” /B WebDev.WebServer.EXE /port:5002 /path:”d:\Projects\myproject\” /vpath:”/Project”
There was never a good story of mocking and testing Web Forms page, handler and module components, but with OWIN that's mostly fixed, since it's very easy to spin up new server that's listening on a port from any console or service application
I'm currently working on a Windows Store Application (Windows 8) for a class and I'm having problems getting my NUnit tests to run.
My Solution/Project setup looks like the following:
TheMetroApp.sln
SQLite-net.csproj - Class Library (Windows Store Apps). Files are pulled from NuGet.
DataModel.csproj - Class Library (Windows Store Apps)
UnitTests.csproj - Unit Test Library (Windows Store Apps). NUnit framework is pulled from NuGet.
TheMetroApp.csproj - A project file which was pulled from one of the Windows SDK examples.
Misc. Dependencies and Utilities
Windows 8 Pro RTM/Visual Studio 2012 RTM
ReSharper 7
NUnit 2.6.1
SQLite (Set up per the instructions here)
UnitTests is dependent upon and references DataModel. DataModel is dependent upon and references SQLite-net. The only thing I have added to the UnitTests project is a single class containing some stub NUnit unit tests. As far as I can tell, these are set up correctly:
[TestFixture]
public class TaskSourceTests
{
#region Private Class Members
private ITaskSource _taskSource;
private String _dbPath;
#endregion
#region Testing Infrastructure
[SetUp]
public void SetUp()
{
// This part makes NUnit/ReSharper have problems.
_dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "UnitTestDatabase.sqlite");
}
#endregion
#region Misc. CRUD stuff
[Test]
public void CreateTaskTest()
{
// Save the task.
Task task = new Task( "Some Task", "lol.", DateTime.Now, false );
_taskSource.Save( task );
// Confirm that it is in the task db.
using( SQLiteConnection db = new SQLiteConnection( _dbPath ) )
{
const String query = "SELECT * FROM Task WHERE Id = ?";
IList<Task> results = db.Query<Task>( query, task.Id );
Assert.True( results.Contains( task ) );
}
}
// ...and so on [but with stubs that are basically Assert.Fail( "" )].
#endregion
}
TheMetroApp is one of the Windows 8 SDK sample projects, but with some custom XAML forms thrown in. I'm not having any problems with this project.
My issue is that none of the Unit Test runners that I have tried to use are working.
When I try to use the official NUnit x86 Test runner (version 2.6.1), my tests fail due to certificate related issues (see here):
UnitTests.TaskSourceTests.CreateTaskTest:
SetUp : System.InvalidOperationException : The process has no package identity. (Exception from HRESULT: 0x80073D54)
ReSharper's NUnit test runner fails for the exact same reason. Unfortunately, it doesn't look like there is currently a workaround for that.
I have also tried using the test runner built into Visual Studio 2012 (through the NUnit Visual Studio Test Adapter). When I try to run my tests using "Run All", I get the following output:
------ Run test started ------
Updating the layout...
Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete. Full package name: "GibberishAndStuff"
No test is available in C:\Projects\project-name\ProjectName\UnitTests\bin\Debug\UnitTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
========== Run test finished: 0 run (0:00:09.4873768) ==========
Something strange I have noticed is that if I select a specific test in the Test Explorer and tell it to run, I get a slightly different error message:
Could not find test executor with URI 'executor://nunittestexecutor/'. Make sure that the test executor is installed and supports .net runtime version 4.0.30319.18010.
This is kind of perplexing because I have the NUnit Test Adapter installed. I'm not seeing anything similar to my issue on the launchpad page for the test adapter.
I'm not really sure where I should proceed from here. If this doesn't work I don't mind reworking my project to use xUnit.net, Microsoft's unit testing framework or something else. It would be pretty awesome if I could get NUnit working though.
Thanks!
I have a Windows 7 Phone app which had the same issue that you have. My solution was to create a separate "linked" project which compiles the code using the standard .net libraries. The linked project will have no issues with unit test / NUnit.
See the following for more information:
http://msdn.microsoft.com/en-us/library/ff921109(v=pandp.40).aspx
http://visualstudiogallery.msdn.microsoft.com/5e730577-d11c-4f2e-8e2b-cbb87f76c044/
I've ported the app to Windows 8 and have no problems running my test cases.
I've just hit the same error message while creating unit tests for an Universal App (W81 + WP81). The only solution here was to stop using NUnit and use MSTest only.