Testing framework for C# WPF application [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have already created C# WPF application and I would like to create test application for same.
I have searched for that on Internet, I have found below test framework :
Nunit
Robot framework
Unit testing
I am confused to select the best test framework for C# WPF application.
Can you please suggest me

Use an accepted pattern such as MVVM to ensure that there’s no business logic in the UI.
Use NUnit or similar to test the business logic.
Don’t bother with automatically testing the view. It should be simple enough so if it looks right, it is right.

I assume your question is about unit test frameworks.
NUnit is well tested and proven to work. I don't know about the other two but there's also Microsoft's one and xUnit. You really should check xUnit out: https://xunit.github.io/docs/why-did-we-build-xunit-1.0.html
It's actually just a matter of preference. Go after the one you feel comfortable with. Test the others and decide. I can recommend you xUnit as I work with it myself. There's no the best.

You don't really need a third-party framework for writing unit test if you don't want to. You could just create a Unit Test Project (Templates->Visual C#->Test->Unit Test Project) using the built-in Visual Studio template.
You would then add a reference to the project where your view model classes are implemented and write unit tests against these:
[TestMethod]
public void SomeTest()
{
var vm = new YourViewModel();
vm.PropertyA = "a";
Assert.IsNotNull(vm.PropertyA);
}
Of course this assumes that you have implemented your application with testability in mind. MVVM is the recommended pattern to use when developing XAML based UI applications. If you haven't learned it yet, you should. MSDN provides a good starting point: https://msdn.microsoft.com/en-us/library/hh848246.aspx.

Related

Picking the right test project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have been learning C# for one and a half year and I also learn Java from time to time. I don't have much experience yet and especially when it comes to testing my code and until now I have always tested manually by interacting with the GUI or writing small test programs. Recently while learning Java I came across JUnit testing and I wondererd if the same exists for Visual C#. In Visual Studio 2017 I have the option of creating a MSTest Test Project, NUnit Test Project, xUnit Test Project or Unit Test Project.
I have found examples of people using these different projects but I couldn't figure out what's the big difference or which one should be used when.
Microsoft has it's own test framework, aptly named 'MSTest', which is a simple and easy way to get started. OFten, you'll see complaints from people who find it slow, however, a few tweaks to the settings here & there, and you'll find it performs briliantly.
However, there are more popular test frameworks such as nUnit, xUnit. All have good documentation on how to get started, and these days, there aren't too many differences between them. xUnit has some neat features that you may find interesting, however, it's first in advanced scenarios that these frameworks differ, and you'll have to have pretty specific needs before you find a limitation.
I would suggest you to start on MSTest, nUnit or xUnit, try them out, make one DLL for each of them in your project and see which one you like more.
The different frameworks are not that very different. I would recomend xUnit or NUnit, I prefer xUnit, but it is more of an syntax issue. I think most of them support parameterized input now. The most important is that you create unit tests!

Shortcut for creating tests / specs in Visual Studio in an associated assembly [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
If I am working on a new class in the C# editor called:
MyCompany.Foo
In the project MyCompany and I wish to create a unit test but in a different assembly it would be nice if I could set up a naming convention and a short cut that would create the test file in a different assembly but in the correct directory with a name similar to the class under test.
For example I would want the above class to generate a test in
MyCompany.Tests.FooTest
Are there any plugins that do this kind of thing or some variant thereof.
With ReSharper installed, there is an extension called "TestCop" which allows you to generate (or else navigate to) a test class by hitting Ctrl-G Ctrl-T. The naming conventions for your test assembly and test class are configurable. So, for example, you can have your test assembly be the name of your assembly under test plus ".Test" and your test classes be the name of your class under test plus a "Spec" suffix.
I can highly recommend it!
You could use T4 templates in order to generate files in different projects; this uses the T4 Toolbox which is a treasure trove of useful things template related. It is also possible to create templates in Visual studio that will create skeletons for you (there are many template types, i'm just linking to the item template)
Finally you could decide to roll out your own custom tool. I did this tool that outputs (albeit ugly) C# code for testing purposes in order to play with PegJS and Handlebar, feel free to tweak if you're interested. Please note that it doesn't interact with VS at all but it was a funny afternoon project

C# test application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I a have a solution containing 25 projects comprised of both C# and managed C++.
I need to test one of the C# project calls but this project is of type "Window application" (Not DLL).
Even though it is a windows application, my requirement is to call only few internal functional calls (Not related to windows form).
I need to create a separate C# test project to call this functionality. Is it possible to do it like this?
Can anyone suggest a way or examples? And one more thing, I cannot modify the existing code.
Is it possible to do it like this?
Yes. Referencing the project you wish to test in a test project is typically how you unit test your code.
Can any one suggest a way or examples?
Create a unit test project, reference the project that contains the code you wish to test, write tests to test the code you wish to test. If you need to refactor the code to make it testable, do so, or see point below.
And one more thing, i don't have any freedom to modify the existing
source code.
In this case, you are going to have to wrap the code in some cleaner interfaces to allow you to test the code.
The book, Working Effectively with Legacy Code by Michael Feathers has some excellent advice on how to get legacy code under test.

Architecture and patterns for developing a custom GUI designer via C# & WinForms [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I only have a vague hint of spec so far, but I'm just testing the waters. I need to create a designer that will be used for creating CBT tasks and workflows. It must cater for custom objects (controls) as well as standard .NET WinForms controls.
I very lightly scanned some papers long ago on using the Visual Studio SDK and deployable design framework, but I can't remember anything meaningful.
I need some resources on building designers in general, with drag and drop, resizing, connectors, and events.
I need some resources on the capabilities of the Visual Studio SDK in regards to my first point.
I would appreciate any recommendations regarding alternative (hopefully open source) technologies and patterns.
I would lurve to write this from scratch, but I can't do that at my client's expense, so I would much prefer to leverage existing artifacts as much as possible.
EDIT: When I first posted, I could not recall that one tool I had in mind was the Visual Studio Shell, which allows me to create a "VS clone", with VS features, but my own branding and DSL type projects.
I have implemented the VS designer in one of my applications, and I'll tell you now - there is not much documentation. Although I achieved a result I am happy with, documentation is slim. Here are some links:
Create And Host Custom Designers With The .NET Framework 2.0
System.ComponentModel.Design Namespace
DesignSurfaceManager Class
There's also the MSDN article called "Extending Design-Time Support".
The only book written on the subject seems to be "Developing .NET Custom Controls and Designers Using C#", which dates back to 2005.
I also find it odd that there's so little information on this subject. Is writing .NET designers unpopular for some reason? It took a while for my exploration of C# to get to the point where learning this subject made sense, and I wonder if I should make the effort.

Where can I find the source for a small, well-designed C# application (for learning purposes)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Can anyone direct me to a smallish C# application that would be symbolic of the "right way" to design a program? I'm looking for a relatively simple (potentially trivial) program from which to analyze and learn.
The application should have a relatively trivial problem to solve and should solve it in a rather straight-forward way while showing off best practices/good object oriented design.
I've been studying C# rather a lot of late, and while I'm becoming confident in my understanding of parts of the .Net framework and the C# syntax, I'm having difficulties with the general concept of design and how a project fits together.
Thanks for any sources you can provide!
There are plenty of projects on this site:
http://www.codeplex.com/
First, take a look at the previous question on this topic. It's at https://stackoverflow.com/questions/143088/open-source-c-projects-that-have-very-high-code-quality-to-learn-from.
To that list I would add:
ASP.NET MVC Storefront (MVC
reference)
SubSonic
Rawr (good Windows Forms app)
All of these are on Codeplex.
A great project that is object oriented and uses best practices is SharpDevelop. You can download the source here: http://www.icsharpcode.net/OpenSource/SD/Download/. It's actually an IDE, so you can use it to write your code too.
I downloaded the source, loaded it up in Visual Studio, compiled it, and ran it in Debug mode... all in about 5 minutes without doing any special setup!
The only catch is that the solution itself is not very small, but is broken into a lot of small projects, so that is why I am recommending it.
You can download something like BlogEngine. If you download the full source version you can set break points and walk thru the code and see how they implement things.
Otherwise there are a ton of projects on codeplex.
Microsoft has a great library of this stuff:
ASP.NET Quick Start Tutorials
ASP.NET Starter Kits and Community Projects

Categories

Resources